Page 1 of 1

Regex question (I believe)

Posted: Mon Jun 26, 2006 6:15 pm
by Luke
Say I wanted to find something like {this} in a file and replace it with whatever I wanted... would this be something I would do with regex or would there be an simpler solution?

If it's a regex thing, can somebody help me out with that? I have tried to understand regex for about 3 years, and it just ends up making me mad.

Posted: Mon Jun 26, 2006 6:26 pm
by RobertGonzalez
Totally regex. Unless you know what is inside the {}, then you could use a str_replace(). But most times these things are used in templating systems and utilize some form of regex. As to what form, well, let's say I studied arrays more than regex. Sorry.

Posted: Mon Jun 26, 2006 9:07 pm
by feyd
Without a lexical definition for the content of the braces:

Code: Select all

#\{.+?\}#s
is pretty much the most open one you can get.