List Info

Thread: Regex question




Regex question
user name
2006-09-01 15:19:29
Hello,

I want a regex for matching a 10 digit number with optional
'*' and '?'
characters for wildcard searches. The * or ? can not appear
in
beginning if alone.

I came up with following regex but unfortunately doesnt work
all the
time. Could anyone please correct me where I am wrong.

^\d(\b(\d+\*\d+)*|(\d+\?\d+)*|(\d*\*$)|(\d*\?$)
b)+

Thanks
superman


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Regex question
user name
2006-09-01 17:22:59
superman wrote:
> Hello,
>
> I want a regex for matching a 10 digit number with
optional '*' and '?'
> characters for wildcard searches. The * or ? can not
appear in
> beginning if alone.

you question is not very clear. Do you mean the * or ? can
not be
stand-alone, and it can be the first character if they are
not
standaloe, like *123

> I came up with following regex but unfortunately doesnt
work all the
> time. Could anyone please correct me where I am wrong.
>
>
^\d(\b(\d+\*\d+)*|(\d+\?\d+)*|(\d*\*$)|(\d*\?$)
b)+

why do you want word boundaries. They look strange and most
possibly, I
think, they will fail many of your matches.

Can you provide us with some samples, i.e. are some of the
following
strings valid:

*
?*
***
*12*34
1234*
12*34?
12?3*4
123?**4
___
Xicheng


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )