How to get everything in the string, but a particular pattern
Posted
by
José Leal
on Stack Overflow
See other posts from Stack Overflow
or by José Leal
Published on 2011-01-07T16:41:15Z
Indexed on
2011/01/07
16:54 UTC
Read the original article
Hit count: 276
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
© Stack Overflow or respective owner