Regular expressions for filtering Alt

Source: Internet
Author: User
Regular Expressions PHP

For PHP to filter the regular expression of ALT, Alt has three kinds of cases, the requirements can be filtered out
alt= "Xxxxxxxxxxxx"
alt= ' xxxxxxxxxxxx '
Alt=xxxxxxxxxxxx

Requirements can be filtered out of the above three kinds of conditions.


Example:







......



Requirements can be filtered in a variety of situations without filtering other content. Thank you.


Reply to discussion (solution)

$s =<<< txttxt;echo preg_replace ('/alt= ([\ ' "]?). +?\b\1/is ', ', $s);





For PHP to filter the regular expression of ALT, Alt has three kinds of cases, the requirements can be filtered out
alt= "Xxxxxxxxxxxx"
alt= ' xxxxxxxxxxxx '
Alt=xxxxxxxxxxxx

Requirements can be filtered out of the above three kinds of conditions.


Example:







......



Requirements can be filtered in a variety of 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 provide may only be suitable for the example I wrote above, I give a practical content, I know the filter out of a problem.





For PHP to filter the regular expression of ALT, Alt has three kinds of cases, the requirements can be filtered out
alt= "Xxxxxxxxxxxx"
alt= ' xxxxxxxxxxxx '
Alt=xxxxxxxxxxxx

Requirements can be filtered out of the above three kinds of conditions.


Example:







......



Requirements can be filtered in a variety of situations without filtering other content. Thank you.
$str = '



';
echo preg_replace ('/(. *) (alt=[\ "\ ')?. *? [\ ' \ ']?\s+) (. *)/', ' $1$3 ', $str);

The method you provide may only be suitable for the example I wrote above, I give a practical content, I know the filter out of a problem.



I know I have a problem with that, and that \b was a last resort.
However, since you can satisfy the data of your example, it will be okay.
You're not going to let me get a list of things that might happen? What are you going to do about it?

$s =<<< TXT



Txt;echo preg_replace ('/alt= ([\ ' "]?). +?\1 (\s|>)/is ', ' $ ", $s);















For PHP to filter the regular expression of ALT, Alt has three kinds of cases, the requirements can be filtered out
alt= "Xxxxxxxxxxxx"
alt= ' xxxxxxxxxxxx '
Alt=xxxxxxxxxxxx

Requirements can be filtered out of the above three kinds of conditions.


Example:







......



Requirements can be filtered in a variety of situations without filtering other content. Thank you.
$str = '



';
echo preg_replace ('/(. *) (alt=[\ "\ ')?. *? [\ ' \ ']?\s+) (. *)/', ' $1$3 ', $str);

The method you provide may only be suitable for the example I wrote above, I give a practical content, I know the filter out of a problem.




Did you test me on the end?

$str =<<< TXT













TXT;
echo preg_replace ('/(. *?) (alt=["\"]?. *? ["\']?) (\s+|>)/', ' $1$3 ', $str);
Forget to lean on the back of the case without spaces, plus allow in the last no space in the situation can be

Thank you very much for two bit!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.