Sublime Forum

How to combine two regex expressions at once

#1

hello, I want to combine this two regex expression, that work very good single:

WORD_1[\s\S]?WORD_2[\s\S]? (match everything from word_1 to word_2 )

and

s/^\s+|\s+$ (remove empty spaces)

I try to combine those 2 expression by putting the sign | between them, like this:

WORD_1[\s\S]?WORD_2[\s\S]?|s/^\s+|\s+$

This will work, but only if I make the operation twice. I need to make the search operation, and replace, at once. Can anyone help me?

0 Likes

#2

to combine two expressions or more, put every expression in brackets, and use: *?

This are the signs to combine, in order of relevance:

  1. ?
    exemple (A)
    ?(B)
  2. |
    exemple A|B
  3. ()()
    exemple (A)(B)
  4. ()|()
    exemple (A)|(B)
0 Likes