Question on RegularExpression

F

fabrice

Hello,

In a search form, i want to permit few characters (see below) and some signs
as - _ / , .
So thios my RegularExpression and it works.

ValidationExpression="[a-zA-Z 0-9-_/,.]{4,20}"


But i'd would like to permit the sign ? in my string, but only one or two
occurence., like this.

Search : 123?456?


I don't manage to do it. All my tests are wrong.


thanks.
fabrice
 
H

Hans Kesting

fabrice said:
Hello,

In a search form, i want to permit few characters (see below) and
some signs as - _ / , .
So thios my RegularExpression and it works.

ValidationExpression="[a-zA-Z 0-9-_/,.]{4,20}"


But i'd would like to permit the sign ? in my string, but only one or
two occurence., like this.

Search : 123?456?


I don't manage to do it. All my tests are wrong.


thanks.
fabrice

You could try this:
([a-zA-Z 0-9-_/,.]+[?]?){0,2)[a-zA-Z 0-9-_/,.]*

but then you lose the maximum-length check.

explanation:
- one or more of your characters
- optionally followed by a ?
- the above repeated 0 to 2 times
- possibly followed by characters

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top