I am trying to locate all matching strings in my content with preg_match_all() but it is returning some random results.
Here's my content:
This is my content but it is completely dynamic...
[[hello_world]]
[[hello-world]]
[[hello world]]
I am wanting to only return this: [[hello_world]]
preg_match_all('/[[[a-z0-9_]+?]]/', $content, $matches);
but it is returning this:
0 => "[[hello_world]]"
1 => "world]]"
2 => "world]]"
I am wanting to only return this: [[hello-world]]
preg_match_all('/[[[a-z0-9-]+?]]/', $content, $matches);
but it is returning this:
0 => "world]]"
1 => "[[hello-world]]"
2 => "world]]"
I am wanting to only return this: [[hello world]]
preg_match_all('/[[[a-z0-9 ]+?]]/', $content, $matches);
but it is returning this:
0 => "world]]"
1 => "world]]"
2 => "[[hello world]]"
Thanks for the help!