[xquery-talk] Problem with regular expression with Xquery

Newman, John W John.newman at viaoncology.com
Wed Feb 24 15:03:10 PST 2010


Try putting parentheses around the last part and add a ?

[0-9]{3}\-[0-9]{3}(&P|P)?

? means 0 or 1 occurrence


From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Kenneth Dougherty
Sent: Wednesday, February 24, 2010 2:52 PM
To: talk at x-query.com
Subject: [xquery-talk] Problem with regular expression with Xquery

Hello,

The following problem has me stumped, and I would be grateful for any help.

I am using a regular expression to test if a document number is correct. The number can end with either 'P,' '&P,' or it may not have an ending value outside of the regular number.

For example, if a valid document number was 503-302, it could be 503-302P, 503-302&P, or just 503-302.

The incorrect regular expression so far is: [0-9]{3}\-[0-9]{3}&P|P.

This expression correctly finds 503-302P and 503-302&P, but of course fails to find 503-302. I've tried putting in other 'or' conditions at the end [e.g., |\s], but nothing has worked out.

Thank you again for your time and help.

Sincerely,

Kenneth Dougherty

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20100224/5d0affed/attachment-0001.htm


More information about the talk mailing list