Please match {my: abc} to & lt; mynameabc & gt; and {my: abc}
$ Content = '{my: abc} {my: CBA} {my: 123} {sys: abc} {field: CBA} {tag: aaa }';
This write is invalid. please modify it.
$ Content = preg_replace ('/{(\ w. +) :( \ w. +)}/I ',' <$1 name = "$2"/> ', $ content );
Only the match starting with "my: sys: fled:" does not match any other matches.
The expected matching result is
{Tag: aaa}
Please reply after testing is feasible. thank you.
Reply to discussion (solution)
echo preg_replace('/\{(my|sys|field)\:(\w+)\}/', '<$1 name="$2" />',$content);
echo preg_replace('/\{(my|sys|field)\:(\w+)\}/', '<$1 name="$2" />',$content);
No changes match unsuccessful
Original: {my: abc} {my: CBA} {my: 123} {sys: abc} {field: CBA} {tag: aaa}
Result: {my: abc} {my: CBA} {my: 123} {sys: abc} {field: CBA} {tag: aaa}
Result: {tag: aaa}
$content = '{my:abc}{my:CBA}{my:123}{sys:abc}{field:CBA}{tag:aaa}';$content = preg_replace('/{(my|sys|field):(\w.+)}/iU', '<$1 name="$2" />',$content);echo $content;
{Tag: aaa}
echo preg_replace('/\{(my|sys|field)\:(\w+)\}/', '<$1 name="$2" />',$content);
No changes match unsuccessful
Original: {my: abc} {my: CBA} {my: 123} {sys: abc} {field: CBA} {tag: aaa}
Result: {my: abc} {my: CBA} {my: 123} {sys: abc} {field: CBA} {tag: aaa}
You can see the effect only when you look at the source code.
Sorry, I am SB. thank you very much!