Page 1 of 1

Regex Question

Posted: Sun Nov 13, 2005 1:30 pm
by Sphenn
Hello everyone.

I am trying to build a regex that will take information from between two delimiters.

The delimiters are "{" and "}". I'm trying to get everything in between those two characters.

I've looked at all the tutorials, but I don't really have a clue.

If anyone could give me a few pointers, that would be great

Thanks,

Sphenn

Posted: Thu Nov 17, 2005 6:27 pm
by RobertPaul
Well ...

Code: Select all

/\{.*\}/
That would do it.

Posted: Thu Nov 17, 2005 7:51 pm
by Nathaniel
I would use

Code: Select all

/{([^}]+)}/
... the negated } will be faster than having to backtrack...

(untested)

Posted: Thu Nov 17, 2005 7:55 pm
by Burrito
to create a reference...

Code: Select all

$pattern = /\{(.*?)\}/;

edit:
damn it! I guess the bbcode or something is killing my escape slashes...there needs to be backslashes right before the { and }