I have a string that will have pipes | in it.
for example:
$string = 'hello | hello <htmltags> etc|Any character';
NO what i want to do is remove last pipe followed by ANy character.
so that my result would be following after preg_replace.
$replaced_string = 'hello | hello <htmltags> etc';
can you help me, what regular expression pattern i should use.
Then you should replace this
with the empty string
\|matches a|[^|]*$matches 0 or more characters that are not a|till the end of the string (because of the$anchor)in php it would look like
The
/around the regex are regex delimitersWhat absolutely every Programmer should know about regular expressions
Disclaimer: My own blog