This is a migrated thread and some comments may be shown as answers.

Reg Expression Help

1 Answer 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Trevor
Top achievements
Rank 1
Trevor asked on 07 Sep 2011, 10:03 PM
I am using a reg exp validator and I can not get the reg expression exactly how I want it. Below is my Reg Ex.

((#\*){1}) | (([0-9\*]{1,9})+-+([0-9\*]{1,9}))


What I want is for the reg Expression to allow either a # or a * one time OR allow a string of [Numbers or *]-[Numbers or *] 0-9 times.

Some examples would be ...

Ex. 1 = *
Ex. 2 = #
Ex. 3 = 12345678-123456789
Ex. 4 = *-1234
Ex. 5 = 1234-*

Please any help would be great!

Thanks,
Trevor

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Oct 2012, 09:28 AM
Hi Trevor,

Try the following Regular expression.

ASPX:
ValidationExpression="((([0-9]{1,9}|[*]))([-])(([0-9]{1,9}|[*]))|([#|*]{1}))"

Regards,
Princy.
Tags
General Discussions
Asked by
Trevor
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or