I would like to replace strings that starts with “[id”, has a middle part unknown and ends in “]” in a $text. I know how to replace strings that starts with “[id” and ends with “]” but I can’t figure out how to include the unknown middle body part as a rule of replace.
Any ideas how to replace like this ?
Thanks.
The following will remove all occurences of
[idsomething]. something will match all characters except for].If you know that something is always a digit, you could use something like this:
For more information about regular expressions, see this website: http://www.regular-expressions.info/.