I use strings with this characters: { and }
Example:
Logged in with IP-Adress {ipAdress}
Or other example:
Your username was {userName}
Now i need a regex to find any strings, i tried this:
preg_match_all('/^{(.+)}/', $string, $matches)
But this don’t find that…
Who can help me here?
{s are special in regular expressions. You need to escape them.Additionally,
^anchors to the start of the line. Your pattern isn’t at the start of a line.Finally, per your comment below, you have more than one such demarcated string per line, so you want to use the non-greedy version of the search
.+?.