Answer the question
In order to leave comments, you need to log in
A collection of regular expression examples?
Share some collection of examples (Pts preferably in Russian) of regular expressions in js
For example, things that I can’t master in any way:
1. Search area: when you need to find what is standing before or after something. And process only what you were looking for.
2. Return one (or more) character before or after the found one. When you are not sure that what you need is where you will look.
And, yes, I googled, read learnJS, but either I'm stupid or the lessons are slow) I'm interested in a selection of examples, and not in solving my problems, because these are hardly my last problems.
Answer the question
In order to leave comments, you need to log in
In general, my problems were solved by something like this construction, which in this example finds everything that is between the triangular brackets and replaces only the desired word there with a new value
someElem.replace(/<.+?>/g, function(str){
return str.replace(/gray/g, '<b class=gray>')
});
Here is a complete guide
https://ru.wikipedia.org/wiki/%D0%A0%D0%B5%D0%B3%D...
Then you just take an online service and test
https://www.google.ru/ ?gws_rd=ssl#newwindow=1&q=%D...
regexlib.com/DisplayPatterns.aspx
PS: I think that the problems you describe can be solved using subpatterns:
console.log(('axxx'.match(/(.)xxx/) || [])[1]); // Находит один любой символ, стоящий перед строкой "xxx"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question