Regular expression for filtering alt
Obtain the regular expression for filtering alt in PHP. alt can be filtered out in three cases.
Alt = "xxxxxxxxxxxx"
Alt = 'xxxxxxxxxxxxxxxx'
Alt = xxxxxxxxxxxx
You must be able to filter out the above three cases.
Example:
......
It is required to filter various situations without filtering other content. Thank you.
Reply to discussion (solution)
$s =<<< TXTTXT;echo preg_replace('/alt=([\'"]?).+?\b\1/is', '', $s);
Obtain the regular expression for filtering alt in PHP. alt can be filtered out in three cases.
Alt = "xxxxxxxxxxxx"
Alt = 'xxxxxxxxxxxxxxxx'
Alt = xxxxxxxxxxxx
You must be able to filter out the above three cases.
Example:
......
It is required to filter various situations without filtering other content. Thank you.
$ Str ='
';
Echo preg_replace ('/(. *) (alt = [\ "\']?. *? [\ "\ ']? \ S +) (. *)/',' $1 $ 3', $ str );
$s =<<< TXTTXT;echo preg_replace('/alt=([\'"]?).+?\b\1/is', '', $s);
The method you provided may only be suitable for the example I wrote above. I will give the actual content and I will know that there is a problem with filtering.
Obtain the regular expression for filtering alt in PHP. alt can be filtered out in three cases.
Alt = "xxxxxxxxxxxx"
Alt = 'xxxxxxxxxxxxxxxx'
Alt = xxxxxxxxxxxx
You must be able to filter out the above three cases.
Example:
......
It is required to filter various situations without filtering other content. Thank you.
$ Str ='
';
Echo preg_replace ('/(. *) (alt = [\ "\']?. *? [\ "\ ']? \ S +) (. *)/',' $1 $ 3', $ str );
The method you provided may only be suitable for the example I wrote above. I will give the actual content and I will know that there is a problem with filtering.
I know that I have a problem with the regular expression. adding that \ B is a last resort.
However, since the data in your example can be satisfied, you can.
You can't let me list the possible situations? What are you doing?
$s =<<< TXT
TXT;echo preg_replace('/alt=([\'"]?).+?\1(\s|>)/is', '$2', $s);
Obtain the regular expression for filtering alt in PHP. alt can be filtered out in three cases.
Alt = "xxxxxxxxxxxx"
Alt = 'xxxxxxxxxxxxxxxx'
Alt = xxxxxxxxxxxx
You must be able to filter out the above three cases.
Example:
......
It is required to filter various situations without filtering other content. Thank you.
$ Str ='
';
Echo preg_replace ('/(. *) (alt = [\ "\']?. *? [\ "\ ']? \ S +) (. *)/',' $1 $ 3', $ str );
The method you provided may only be suitable for the example I wrote above. I will give the actual content and I will know that there is a problem with filtering.
Are you sure you want to test me?
$ Str = <TXT
TXT;
Echo preg_replace ('/(.*?) (Alt = ["\ ']?. *? ["\ ']?) (\ S + |>)/',' $1 $ 3', $ str );
I forgot to lean on the situation where there is no space at the end. I can add the case where there is no space at the end.
Thank you very much!