Skip to main content
Participating Frequently
April 21, 2012
Question

RegExp for excluding special characters in a string.

  • April 21, 2012
  • 1 reply
  • 26188 views

Hi All,

Im using Flex RegExpValidator. Can anyone suggest me the correct expression to validate this condition?....

I have tried this expression :----- /^[^///\/</>/?/*&]+$/...But in this it is also negating the alphabets.Also I have tried with opposite condition that in the String we should have alphabets and the expression is:-- ([a-z]|[A-Z]|[0-9]|[ ]|[-]|[_])*..... Please can anyone help me on this.

Thanks in advanced to all.

Munira

This topic has been closed for replies.

1 reply

_spoboyle
Inspiring
April 23, 2012
munira06Author
Participating Frequently
April 24, 2012

Hi ,

Thanks for your reply.I have tried this condition.

And got following result:--

If you give only alphabets with no special symbols.The expression is valid

that is what is my requiremnet.

If you give only special characters .Expression is invalid what is our

requiremnet.

But if you give mixed expression of Special symbols and alphanumeric

characters it is considering it as Valid .

iwr ote:

**

Re: RegExp for excluding special characters in a string. created by

spoboyle <http://forums.adobe.com/people/spoboyle> in Flex - View the

full discussion <http://forums.adobe.com/message/4354492#4354492

_spoboyle
Inspiring
April 24, 2012

did you use

var pattern:RegExp = /^[a-zA-Z0-9 -_]*$/;

or

var pattern:RegExp = /^[a-zA-Z0-9 \-_]*$/;

remember - needs to be escaped since it's used to indicate a range of values