I have strings like : {$foo.bar}
and {$foo.bar.anything}
WHERE : foo AND bar AND anything === alphanumeric
i want to match the above 2 strings in PHP
via preg_match(regular expression)
except those without any dot for example : {$foo}
Your help will be much appreciated, thanks.
/{\$[\da-z]+(?:\.[\da-z]+)+}/i
matches
{$foo.bar}
{$foo.Bar.anything}
{$foo.bar.anything1.anything2.anything3}
{$foo.bar.anything.a.b.c}
does not match
{$foo}
{$foo.}
{$foo bar}
{$foo.bar anything}
{$foo.bar......anything..}
{$foo.bar.anything.}
{$foo.bar.anything.a.b.c..}
Adopted Joe’s PCRE case-insensitive modifier to shorten it a bit.
Special thanks to sln for keeping me on my toes until it’s perfect. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With