Skip to content
Advertisement

Tag: pcre

Regexp: find all occurences on same string inside brackets

i already few days trying write some regexp for replacing all : inside brackets, pls help me, so i have string: how i can get all : and replace it with / ? i trying something like: but it’s find only last : Answer In a general case, it will look like See the regex demo. Remove the last +

When do I need u-modifier in PHP regex?

I know, that PHP PCRE functions treat strings as byte sequences, so many sites suggest to use /u modifier for handling input and regex as UTF-8. But, do I really need this always? My tests show, that this flag makes no difference, when I don’t use escape sequences or dot or something like this. For example preg_match(‘/^[da-f]{40}$/’, $string); to check

Advertisement