O
O
Optimus2015-09-21 16:26:47
JavaScript
Optimus, 2015-09-21 16:26:47

How to fix regular expression in JS?

regexr.com/3br05
product-spec is in the first line
product-minicard in the last line
And if you remove line breaks, everything works regexr.com/3br08
Why? I have the m modifier! Well, how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2015-09-21
Pyan @marrk2

product-spec([\S\W]*?)product-minicard

S
Sergey Novikov, 2015-09-21
@BOOMER_74

You answered your own question - there are hyphens in the line. You need something like this: The m
modifier affects the work of ^ and $ (in other languages, the behavior may be different), read about it in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question