
July 31st, 2011, 01:02 PM
|
|
|
I'd try something different, than the word boundary approach. I'm not entirely sure, if that works for JS, but please try, if this fits your needs:
Code:
/^((^|~)(\d{5}))+~?$/
The idea is to match five figures, which follow either the start of a given string or a ~. To make your "ok case" possible, the optional ~ before the end of the given string is appended to the pattern. Unfortunately, this would allow for a string like 12345~12345~ and you didn't say, what should happen in this case.
Regards, Jens
|