I’m trying to parse the string:
[code]
Test link() filter %link(filterTest, http://www.ez-ms.com, Link Text, parent_id=x, user_id=tony, title=Link Test) and trailing text.
And this is the 2nd link() test for %link(filterTest2, http://www.ez-ms.com, 2nd Link Text, parent_id=x, user_id=tony2, title=Link Test2).
Using this preg_match_all() call:
[code]
preg_match_all(‘;%link((.*)[^)];im’, $str, $matches);
Without the ‘U’ modifier it returns:
[code]
matches:Array
(
[0] => Array
(
[0] => %link(filterTest, http://www.ez-ms.com, Link Text, parent_id=x, user_id=tony, title=Link Test) and trailing text.
[1] => %link(filterTest2, http://www.ez-ms.com, 2nd Link Text, parent_id=x, user_id=tony2, title=Link Test2).
)
[1] => Array
(
[0] => filterTest, http://www.ez-ms.com, Link Text, parent_id=x, user_id=tony, title=Link Test) and trailing text.
[1] => filterTest2, http://www.ez-ms.com, 2nd Link Text, parent_id=x, user_id=tony2, title=Link Test2)
)
)
And with the ‘U’ modifier it returns:
[code]
matches:Array
(
[0] => Array
(
[0] => %link(f
[1] => %link(f
)
[1] => Array
(
[0] =>
[1] =>
)
)
It does not seem to want to recognize the [^)] termination of the pattern space.
Can anyone help? I would like $matches to contain the arguments inside the %link(….) text so I can parse them appropriately. But I’m kind of stumped. I’ve tried changing the pattern terminator to [^)
Any help would be greatly appreciated.