PHP Regex: Can I put an end of string $ in a range? -


can put end of string character in range this:

$string=preg_replace('/([a-z])([ \,$])/','$2',$string); 

so matches lowercase letter, either space, comma or end of string?

you can use alternation:

([ ,]|$) 

if use $ inside character class matches literal dollar sign.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

c - getting error: cannot take the address of an rvalue of type 'int' -

How to merge four videos on one screen with ffmpeg -