Reputation: 23
How to get 'text' from this string:
{L[text]}
?
I tried
\{L\[*\]\}
but it doesnt work.
Upvotes: 1
Views: 91
Reputation: 5213
The allowed characters class is missing:
\{L\[(\w*)\]\}
Where \w = [a-zA-Z0-9]. Required text is in group 1.
Upvotes: 3
Reputation: 22592
<?php
$s = "{L[hello you]}";
preg_match('/\{L\[(.*)\]\}/', $s, $matches);
print_r($matches);
Upvotes: 0