Santhosh
Santhosh

Reputation: 11788

unable to select between two comma and A word using regex

I have a text like

 aparna mall, indore, mahavir road <br>Map

I want to select " mahavir road " that is between , and <br>Map. Because i have so many such lines,

I tried ,(.*)<br>Map

it selects

     , indore, mahavir road <br>Map

i want to to select only from the last comma

how to use regex to select. Also any good link with examples of regex.

Upvotes: 2

Views: 1148

Answers (2)

Toto
Toto

Reputation: 91415

Use ungreedy notation:

.*,(.*?)<br>Map

or

,([^,]*)<br>Map

The last will match a comma an capture every thing that is not a comma before <br>Map

Upvotes: 1

Sabuj Hassan
Sabuj Hassan

Reputation: 39365

This regex will work for you:

,([^,]*)<br>Map

Try it online here.

Upvotes: 1

Related Questions