G
Guest
Hi all,
I need to check a string for valid characters. The regular expression that I
am working is long and I try to make it short. There are many 'or' condition
in the expression, so if I can find answer to the following question then I
can make the reg exp shorter and nicer.
Now example: There is a word that could be 2 or 3 characters. First
characters should be "a" and the last character should be "d". The middle
character is either "n" or nothing. My regular expression looks like:
[a][n][d]|[a][d]
Is there a way to make the "d" optional as character d or nothing and not
use (|).
Thanks in advance,
Roy
I need to check a string for valid characters. The regular expression that I
am working is long and I try to make it short. There are many 'or' condition
in the expression, so if I can find answer to the following question then I
can make the reg exp shorter and nicer.
Now example: There is a word that could be 2 or 3 characters. First
characters should be "a" and the last character should be "d". The middle
character is either "n" or nothing. My regular expression looks like:
[a][n][d]|[a][d]
Is there a way to make the "d" optional as character d or nothing and not
use (|).
Thanks in advance,
Roy