Regex: Select Text/String Between Symbols That Contains Another Symbol (Tags That Contains Specific String)

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

2 Answers

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

Explanation:

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

Screenshot from notepad++:


  • 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):

Screenshot (after):

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest