Is the syntax for standardizing a standard expression

Is the syntax for standardizing a standard expression? That is, if I write a regular expression in C ++, it will work in Python or Javascript without any changes.

+3
source share
3 answers

No, there are several dialects of regular expressions.

They usually have many common elements.

Some popular ones are listed and compared here .

+8
source

Simple regular expressions, mostly yes. However, there are differences across the entire spectrum of programming languages.

0
source

, , :

  • JavaScript ( \ \s \\s), /. /. JS RegExp, .

    /^\w+$/i new RegExp("^\\w+$", "i") .

  • PHP ( - , ). .

    "|[0-9]+|" #[0-9]+#

  • Python and C # support raw strings (not limited to regular expressions, but very useful for writing regular expressions), which allow you to write unescaped backslashes in your regular expression.

    "\\d+\\s+\\w+"can be written in both r'\d+\s+\w+'Python and @'\d+\s+\w+'C #

  • Constraints such as \<, \Aetc., are not supported globally.

  • JavaScript does not support lookbehind and the flag DOTALL.
0
source

Source: https://habr.com/ru/post/1736310/


All Articles