i already few days trying write some regexp for replacing all : inside brackets, pls help me, so i have string:
render('MyBundle:Default:index.html.twig') or render('MyBundle::Default::index.html.twig')
how i can get all : and replace it with / ? i trying something like:
render(.*([:])
but it’s find only last :
Advertisement
Answer
In a general case, it will look like
(?:G(?!^)|render(')[^':]*K:+
See the regex demo. Remove the last +
if you need to replace each :
with a /
.
Details:
(?:G(?!^)|render(')
–render('
or the end of the previous match[^':]*
– zero or more chars other than'
and:
K
– match reset operator that discards the text matched so far:+
– (the only text that is finally put into the match value and eventually replaced) one or more colons.