Sublime Forum

Regular expression problem?

#1

Hi! Sublime won’t find my regexp when i’m using \s and puts error. Is it bug or wrong regexp?


for tests i’m using that text:

<div id="crumbs"> <a href="<!--#echo var="basic_url_ssl" -->inside/index.shtml">Главная</a> // <span>Впечатления</span> </div>

0 Likes

#2

I am still have to find my way on sublime regex implementation, but try

(?s)

(.+?)

I hope i explain it right:
(?s) => take expression as single line search ( means: the dot should match \n too)
(.+?) => match one-or-more of any sign, but be non-greedy to stop at first found “”

In my testings last weeks i had different results i think, but this works for me for your examples on 2181.

0 Likes

#3

(\s.) is really nasty to evaluate. The error message basically says that the effort to evaluate it was too complicated. Think through what this is asking for: any combination of space characters followed by any combination of characters, repeated as many times as needed. So if the text being searched is a single space character, all is well. There’s exactly one way to match it. If the text is two space characters, the match could be: \s matches both spaces, .* matches nothing, ()* matches exactly once; \s matches first space, .* matches second space, ()* matches exactly once; \s matches one space, .* matches nothing, ()* matches twice. So there are three possible matches. Now try three space characters and see how fast the number of possible matches blows up. My guess is that there are about 20 ways to match. And as you add more characters to the string to be matched, the number of possible matches becomes astronomical. Sublime gave up in despair.

What part of the text are you trying to pick out?

0 Likes