Kirill Reva
Kirill Reva

Reputation: 1097

How to write regular expression that will catch up following

ticket number: 6666
ticket number : 6666
ticket #6666
ticket # 6666

i tried this one ticket[ \t]+(number|#)?[: \t]+([0-9]+) but it does not work for "ticket #6666"

Could anybody help?

Upvotes: 0

Views: 110

Answers (2)

Shawn Lehner
Shawn Lehner

Reputation: 1323

Try something like this: ticket[\s\t]+(number|#)[:\s\t]*([0-9]+)

Also, if you don't already use it I would recommend http://regexpal.com/ to help you with your testing. It is a great resource to quickly see what is being matched by your expression.

Upvotes: 0

geekosaur
geekosaur

Reputation: 61449

Close; you want the colon/space to be optional.

ticket[ \t]+(number|#)?[: \t]*([0-9]+)

Upvotes: 4

Related Questions