preg_replace and regular expression


I need to remove anything between { and } with a preg replace in PHP

2014-12-18 20:03:51gstlouis


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)

2014-12-18 20:06:11