preg_replace and regular expression | |
---|---|
Subject: | |
I need to remove anything between { and } with a preg replace in PHP | |
2014-12-18 20:03:51 | gstlouis |
/{(.*?)}/ That means, match any character between { and }, but don't be greedy - match the shortest string which ends with } (the ? stops * being greedy). The parentheses let you extract the matched portion. example: preg_replace('/{(.*?)}/', '', $folder)
Another way would be /{([^}]*)}/ This matches any character except a } char (another way of not being greedy) | gstlouis |
2014-12-18 20:06:11 | |