iDrugov2017-03-25 00:08:15
iDrugov, 2017-03-25 00:08:15

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

3 answer(s)
iDrugov, 2017-06-23

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>')

Vasya Pupkin, 2017-03-25

Here is a complete guide
Then you just take an online service and test
https://www.google.ru/ ?gws_rd=ssl#newwindow=1&q=%D...

m-haritonov, 2017-03-25

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 question

Ask a Question

731 491 924 answers to any question