Reputation: 4332
I have the following regex:-
^(?:\[ [^\]]+ \]) ([\-\£]{1,2}[0-9]+\.[0-9][0-9]?)?
And the following text:-
John Doe
+++++++++++++++++++++++++++++++++++++++++++
Blah blah
+++++++++++++++++++++++++++++++++++++++++++
[ √ ] £3.00 Red
[ √ ] £2.00 Blue
[ √ ] £55.55 Yellow
[ √ ] -£41.75 PAYMENT
[ √ ] £5.00 Green
[ √R ] £10.00 Pink
+++++++++++++++++++++++++++++++++++++++++++
Belugh
+++++++++++++++++++++++++++++++++++++++++++
Blah blah
Blah
The regex works ok and matches:-
£3.00
£2.00
£55.55
-£41.75
£5.00
£10.00
What I want to do though is to have the regex match the '£' but not return it in the capturing group.
So the results would be like this:-
3.00
2.00
55.55
-41.75
5.00
10.00
The important bit is the '-' character which should remain, but occurs before the '£' character.
Theres a fiddle here
Upvotes: 6
Views: 17734
Reputation: 19
I did this by including the "£" in the capture group and then simply replacing that symbol with "nothing" from the matched results in the language I'm working in.
Upvotes: 0