How to get everything in the string, but a particular pattern
- by José Leal
Yet another regexp question:
I have a string as the following,
"This is a string, and I have a priority !1"
So I want to build a regexp that extracts my priority, which is this number 1 preceded by the "!".
To extract it is very easy, "!([1-4])". But now I want to extract the text, leaving it out! How can I do that?
DETAIL: The !1 can be anywhere in the string, so this is also perfectly fine:
"This is a string, !1 and I have a priority"
Thanks!
UPDATE: I'm using scala