A sentence is not understood

Source: Internet
Author: User
preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches)

The |\s| in this regular () What does it mean? Does anyone know?

Reply content:

preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches)

The |\s| in this regular () What does it mean? Does anyone know?

I'll explain every part to the master.

#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i

On both sides # is the PCRE delimiter, and the last one i indicates the case is ignored.

(^|\s|\()

The string begins with either a space separation or an opening parenthesis. This section is an unnamed grouping.

((http(s?)://)|(www\.))

Match http:// or https:// maybe www. . This section is an unnamed grouping, which is divided into two unnamed groupings.

(\w+[^\s\)\<]+)

Match at least one alphanumeric number, and then match at least one character that is not a space, a closing parenthesis, or a left angle bracket. Here is another unnamed grouping.

End.

Recommended two debug regular sites:

    • Debuggex interface, powerful, support multi-lingual regular
    • Regexper is better looking, only support JavaScript regular
  • 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.