Reputation: 53
I want to take DDEERR
as a result in regex. My sample string is:
("NNNS" lllsds 4.5 ddsdsd "DDEERR")
I used (?<=\s*\s*").*?(?=")
for all strings between ""
, but I couldn't take the last one only (or before the right parentheses).
Do you have any ideas? Thanks.
Upvotes: 0
Views: 40
Reputation: 522741
I would just make good use of greedy dot here:
^.*"(.*?)".*$
The idea here is that the first .*
will consume everything up until the last term appearing in double quotes. Then, we capture the text inside those double quotes as the first (and only) capture group. Follow the link below to see a working demo.
Edit:
If you really need to do this without any capture groups at all, then we can try writing a pattern with lookarounds:
(?<=")[^"]+(?="[^"]*$)
Upvotes: 2