Challenge JavaScript Regular Expressions two questions per day (2)

Source: Internet
Author: User

Previous Article Next article

Question reference answer in previous article

First question:

Original question requirement: slightly.

Answer: Right.

Note: The title refers to "some" rather than all of the 18 characters, please follow the second question to understand correctly.

The second question:

The original question requires:

Given string
"Ab Dword1=243[asd\fedsf-]234ff/sdfsf{dkdkd", how to find out all of the regular expression meta-characters.

The answers are as follows:

The metacharacters in the target string has no special meaning and can be placed directly inside the regular expression only if it exists as a normal character, except that the backslash character "\" must be escaped with a backslash. In addition, the left-hand bracket character "]" also needs to be considered, because we need a character class to enumerate these metacharacters, so the left-hand bracket character "]" needs to be handled separately. In addition, the subject also examines the grouping and selection techniques. To integrate the above, we can refer to the following options:

var p=/([[{} ()] *+=/.:\ \^$|])| (])/g;
var s= ' ab DWORD1=243[ASD\FEDSF-]234FF/SDFSF{DKDKD ';
S.match (P);

The new single topic is listed below

(1). Given the regular expression/^ (SE)? [0-9] {12}$/, the string that satisfies this match condition is:
A "123456789123"
B "SI12345678"
C "1234567890"
D "Esx1234567y"

(2). Given regular expressions
/^[0-5]? [0-9]$/, the string that satisfies this match condition is:
A "99"
B "009"
C "0009"
D "10"

Previous Article Next article

This article is from the "Green Peak" blog, please make sure to keep this source http://zhuxianzhong.blog.51cto.com/157061/1691074

Challenge JavaScript Regular Expressions two questions per day (2)

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.