4

I want to select all text between => and => only if contains [ or ]

I love you => predici-video [date] => between myself and her.

so, only this => predici-video [date] =>

1
  • 4
    This smells so badly of an XY problem... I'm sure if you post the actual source, and what you're trying to do, there're better ways than a single RegEx... maybe mutliple RegEx instead... so it is easier to read.
    – Nelson
    Commented Jul 20, 2020 at 2:41

2 Answers 2

6

Search for : =>.*(\[|\]).*=>

Explanation:

  • .* - zero or more characters
  • (one|two) - one or the other
  • \[ - the character [ escaped.

Screenshot from notepad++:


enter image description here

4
  • Ctrl+F
  • Find what: (?<==>)[^=>]*[][][^=>]*(?==>)
  • CHECK Wrap around
  • CHECK Regular expression
  • Find All in Current Document

Explanation:

(?<==>)     # positive lookbehind, make sure we have => before
[^=>]*      # 0 or more any character that is not = or >
[][]        # character class, matches [ or ]
[^=>]*      # 0 or more any character that is not = or >
(?==>)      # positive lookahead, make sure we have => after

If you want to catch also =>, use: =>[^=>]*[][][^=>]*=>


Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

2
  • hello @Toto, can you make the second case, to select also the => before and after those words ?
    – Just Me
    Commented Jul 19, 2020 at 20:21
  • 1
    @JustMe: I've already put a comment in bold in the answer, just after explanation. Be aware that the other answer doesn't work if you have multiple text to catch in a single line.
    – Toto
    Commented Jul 20, 2020 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .