Gauri deshmukh
Gauri deshmukh

Reputation: 89

How to create regex to not to accept only special character or number

I how to create regex to not to accept only special character or number. for eg:

it should throw error if string contain :

  1. @$%^^@
  2. 1231232

but should not throw error if string contain :

  1. hi@
  2. hi
  3. hi@1
  4. hi4
  5. @hi

Upvotes: 1

Views: 99

Answers (2)

B. Desai
B. Desai

Reputation: 16436

Simply use regex which allow alpha bates compulsory

/.*[a-z]+.*/i

Upvotes: 2

Anand Pandey
Anand Pandey

Reputation: 2025

Try this regex and let me know. It is also accept white space:

/^[ A-Za-z0-9_@./#&+-]*$/

Upvotes: 0

Related Questions