regex - Regular Expression does not match correct words -


i have problem. have regex:

([\w ]*[^'entre']{1}) entre ([\w ]*) y ([\w ]*) 

and possible strings match are:

  • av cordoba entre medrano y gascon
  • esmeralda entre av rivadavia y lavalle
  • av cor1doba entre entre rios y suipac2ha
  • monroe entre aizpurra y av de los constituyentes

the thing is, regular expression matches first 3 strings, other not being matched , don't know why

can me?

thanks in advance

edit

the strings names of streets , intersections of them. so, want find expression , replace in form:

street1/street2-street3

for first example string, replacement looks like

av cordoba/medrano-gascon

and ^['entre] there because street name can contain string "entre", , must take name of street

edit

i found solution. have use *([\w ]*(?<!entre)) entre ([\w ]*) y ([\w ]*)*

thank all

$pattern = (.*?)(?: entre )(.*?)(?: y )(.*?$)

see demo

it can match string containing "entre" first street name.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -