Fix name of JavaScript
This commit is contained in:
parent
3b14ed8185
commit
c5ce5578fc
32 changed files with 61 additions and 61 deletions
|
@ -255,7 +255,7 @@ There exist following character classes:
|
|||
|
||||
...But that's not all!
|
||||
|
||||
Modern Javascript also allows to look for characters by their Unicode properties, for instance:
|
||||
Modern JavaScript also allows to look for characters by their Unicode properties, for instance:
|
||||
|
||||
- A cyrillic letter is: `pattern:\p{Script=Cyrillic}` or `pattern:\p{sc=Cyrillic}`.
|
||||
- A dash (be it a small hyphen `-` or a long dash `—`): `pattern:\p{Dash_Punctuation}` or `pattern:\p{pd}`.
|
||||
|
|
|
@ -2,7 +2,7 @@ We need to find the beginning of the comment `match:<!--`, then everything till
|
|||
|
||||
The first idea could be `pattern:<!--.*?-->` -- the lazy quantifier makes the dot stop right before `match:-->`.
|
||||
|
||||
But a dot in Javascript means "any symbol except the newline". So multiline comments won't be found.
|
||||
But a dot in JavaScript means "any symbol except the newline". So multiline comments won't be found.
|
||||
|
||||
We can use `pattern:[\s\S]` instead of the dot to match "anything":
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ The typical situation -- a regular expression works fine sometimes, but for cert
|
|||
|
||||
In a web-browser it kills the page. Not a good thing for sure.
|
||||
|
||||
For server-side Javascript it may become a vulnerability, and it uses regular expressions to process user data. Bad input will make the process hang, causing denial of service. The author personally saw and reported such vulnerabilities even for very well-known and widely used programs.
|
||||
For server-side JavaScript it may become a vulnerability, and it uses regular expressions to process user data. Bad input will make the process hang, causing denial of service. The author personally saw and reported such vulnerabilities even for very well-known and widely used programs.
|
||||
|
||||
So the problem is definitely worth to deal with.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
# Unicode character properies \p
|
||||
|
||||
[Unicode](https://en.wikipedia.org/wiki/Unicode), the encoding format used by Javascript strings, has a lot of properties for different characters (or, technically, code points). They describe which "categories" character belongs to, and a variety of technical details.
|
||||
[Unicode](https://en.wikipedia.org/wiki/Unicode), the encoding format used by JavaScript strings, has a lot of properties for different characters (or, technically, code points). They describe which "categories" character belongs to, and a variety of technical details.
|
||||
|
||||
In regular expressions these can be set by `\p{…}`. And there must be flag `'u'`.
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ To grasp the use case of `y` flag, and see how great it is, let's explore a prac
|
|||
|
||||
One of common tasks for regexps is "parsing": when we get a text and analyze it for logical components, build a structure.
|
||||
|
||||
For instance, there are HTML parsers for browser pages, that turn text into a structured document. There are parsers for programming languages, like Javascript, etc.
|
||||
For instance, there are HTML parsers for browser pages, that turn text into a structured document. There are parsers for programming languages, like JavaScript, etc.
|
||||
|
||||
Writing parsers is a special area, with its own tools and algorithms, so we don't go deep in there, but there's a very common question: "What is the text at the given position?".
|
||||
|
||||
|
@ -15,7 +15,7 @@ For instance, for a programming language variants can be like:
|
|||
- Or an operator `pattern:[+-/*]`?
|
||||
- (a syntax error if it's not anything in the expected list)
|
||||
|
||||
In Javascript, to perform a search starting from a given position, we can use `regexp.exec` with `regexp.lastIndex` property, but that's not what we need!
|
||||
In JavaScript, to perform a search starting from a given position, we can use `regexp.exec` with `regexp.lastIndex` property, but that's not what we need!
|
||||
|
||||
We'd like to check the match exactly at given position, not "starting" from it.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue