Matching mode missing by regular expressions in JS (single row Mode)

Source: Internet
Author: User

The single-row mode allows the decimal point (.) to match any character (from RegEx match tracer) including the line break (\ n ).

According to <Microsoft Windows Script technology> CHM:

The decimal point (.) matches any single character except "\ n. To match any character including '\ n', use a pattern like' [. \ n.

There are only three regular expression object modes:

G (search for all occurrences of the pattern in full text)

I (Case Insensitive)

M (multi-row search)

That is, there is no single row matching mode.

However, as mentioned in the CHM documentTo match any character including '\ n', use a pattern like' [. \ n] '.


(Here is an excerpt from: Regular Expression: how to match all characters)


Decimal point (

.) The number of digits in the middle of [] turns into a real decimal point (\.)

If you do not believe it, you can test it like this:

ASDFASDF <span style = "font-size: 22px"> ASDFASDF </span> ASDFASDF

Regular Expression:

<Span style = \ "font-size \: 22px \"> [^.] + </span>

The matching is successful.

The final result should be either (. | \ n) or (. | \ n)

In the manual, [. \ n] indicates that any character is incorrect (it is also the original saying, haha)

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.