PHP regular internal chain exclusion alt method PHP now needs to implement the internal chain function, replace the keyword with the tag, but alt also has a keyword replacement, it will cause an error,
I want to replace the keywords in alt with other characters and then replace them
$ Newsinfo [content] = preg_replace ("/(? <= Alt = \ ". *) (combat )(? =. * \ ")/", "& % ","
However, it seems that this write is not matched. I have no problem in the regular expression tool testing. Is there a problem with the regular expression I wrote? Is there any way to implement it? thank you.
Reply to discussion (solution)Php (? <= Pattern) assertions are fixed-length
What are you about is not long (? <= Alt = \".*)
Echo preg_replace ('/alt = ". +? (Combat). +? "/'," & % ",'');
Echo preg_replace ('/alt = ". +? (Combat). +? "/'," & % ",'');
In this case, replace the entire alt. I just want to replace the keywords contained in alt.
Php (? <= Pattern) assertions are fixed-length
What are you about is not long (? <= Alt = \".*)
Is there any way to achieve this by replacing only the keywords in alt? Echo preg_replace ('/alt = "(. + ?) (Combat) (. + ?) "/', 'Alt =" $1 & % $3 "','');
$ Html = 'combat Jianghu '; echo preg_replace ('#(? = [^>] * (? = <(?! /A>) | $) # ',' \ 0', $ html );
Fighting rivers and lakes
Echo preg_replace ('/alt = "(. + ?) (Combat) (. + ?) "/', 'Alt =" $1 & % $3 "','');
Thank you. is PHP regular expression different from others? I used the regular expression tool to match different results from php.
$ Html = 'combat Jianghu '; echo preg_replace ('#(? = [^>] * (? = <(?! /A>) | $) # ',' \ 0', $ html );
Fighting rivers and lakes
Thank you.
Does php regular expressions differ from others? Where is the difference, or the knowledge written in that book? The manual is in English.
Some online tutorials also mentioned
The contents of a lookbehind assertion are restricted such that all the strings it matches must have a fixed length.
The content limit of a tracing asserted. all strings must have a fixed length.