Javascript Regular Expressions

Source: Internet
Author: User

Preface: For "railroad diagrams", excerpted from the Network: http: // 202.207.0.245: 9001/jisuanjifazhanshi/Tuling/19.htm

We have seen that BNF in many languages is actually ebnf, but this E word is often ignored. When combined with BNF, there are also images that often look like railway maps, called syntax charts or syntax digrams, or railroad digrams ), this is also designed and invented by Wurth. The descriptive ability of this graphic marking method is equivalent to BNF, but of course it is easier to read and understand, and more intuitive.

P.s: Unfortunately, the source address graph is incomplete, otherwise ......

Regular expressions may be complicated (slightly less terse), but the correctness will be improved (slightly easier to use correctly ).
Javascript Regular Expressions Do not support blank spaces, so annotations are not supported. The reason for good parts is actually a security reason:

This is a participant concern when the are used in security applications for scanning and validation.

But on the one hand, the book puts forward the following:

If you cannot read and understand a regular expression, how can you have confidence that it will work correctly for all input?

Finally, some helplessness was revealed:

Yet, despite their obvious drawbacks, regular expresssions are widely used.

What is sloppy regluar experssions? Is the regular expression corresponding to rigorous regular expresssions. Although easy to write, it is the source of many security problems !?

Sloppy regular expressions are a popluar source of security exploits.

D.C points out that the Regexp library of JS has the least compatibility issues, because the core of this tool is very complex and generally won't be changed much. Note that writing regular expressions in literal mode is actually sharing an instance. For example:
Function makematcher () {<br/> return/A/GI; <br/>}< br/> var x = makematcher (); <br/> var y = makematcher (); <br/> // beware: X and Y are the same object! <Br/> X. lastindex = 10; <br/> alert (Y. lastindex); // 10To put it bluntly, the design is the flyweight mode in the design mode. Looking back at a previous bug, I don't know. Now I have reached this point, and I finally got a little eye on it ...... 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.