I'm trying to run this regex but it stuck my console. Why?
var str = "Шедевры православной музыки - 20 золотых православных песен";
str.match(/^(([\u00C0-\u1FFF\u2C00-\uD7FF]+[^a-z\u00C0-\u1FFF\u2C00-\uD7FF]*)+) [a-z]+[^\u00C0-\u1FFF\u2C00-\uD7FF]*$/i);
Problems occurring in Node. js application deployments can have a range of symptoms, but can generally be categorized into the following: Uncaught exception or error event in JavaScript code. Excessive memory usage, which may result in an out-of-memory error.
If your JavaScript doesn't work as you expected it to, that might mean you have a bug in your code. Typos are a common source of bugs in JavaScript. If your script isn't working, check the following: Missing punctuation.
Scalability challenges js is a single-threaded process. This makes app scaling a bit difficult for Node. js web app developers. Moreover, a single-threaded process makes it practically impossible to execute other code in parallel.
An error in Node. js is any instance of the Error object. Common examples include built-in error classes, such as ReferenceError , RangeError , TypeError , URIError , EvalError , and SyntaxError .
Your regex causes catastrophic backtracking (see a demo of your regex here) due to (([\u00C0-\u1FFF\u2C00-\uD7FF]+[^a-z\u00C0-\u1FFF\u2C00-\uD7FF]*)+)
part. As [^a-z\u00C0-\u1FFF\u2C00-\uD7FF]*
can match zero characters, you basically have a classical (a+)+
-like pattern (cf: ([\u00C0-\u1FFF\u2C00-\uD7FF]+)+
) that causes backtracking issue.
To get rid of it, you need to make sure the subpatterns are compulsory inside the grouping, and apply a *
quantifier to the whole grouping:
^([\u00C0-\u1FFF\u2C00-\uD7FF]+(?:[^a-z\u00C0-\u1FFF\u2C00-\uD7FF]+[\u00C0-\u1FFF\u2C00-\uD7FF]+)*) [a-z]+[^\u00C0-\u1FFF\u2C00-\uD7FF]*$
See regex demo
Here, [\u00C0-\u1FFF\u2C00-\uD7FF]+(?:[^a-z\u00C0-\u1FFF\u2C00-\uD7FF]+[\u00C0-\u1FFF\u2C00-\uD7FF]+)*
matches:
[\u00C0-\u1FFF\u2C00-\uD7FF]+
- one or more character from [\u00C0-\u1FFF\u2C00-\uD7FF]
ranges(?:[^a-z\u00C0-\u1FFF\u2C00-\uD7FF]+[\u00C0-\u1FFF\u2C00-\uD7FF]+)*
- zero or more sequences of:
[^a-z\u00C0-\u1FFF\u2C00-\uD7FF]+
- one or more characters other than those from the a-z\u00C0-\u1FFF\u2C00-\uD7FF
ranges[\u00C0-\u1FFF\u2C00-\uD7FF]+
- one or more characters from the \u00C0-\u1FFF\u2C00-\uD7FF
ranges.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With