Glam Prestige Journal

Bright entertainment trends with youth appeal.

This is the line:

I love you and George loves IOANA but also Mihai is my enemy.

I want to match 2 words before IOANA, and also 2 words after IOANA

The Output should be:

I love you and IOANA Mihai is my enemy.

I believe my regex must be upgrade a little bit, as to work:

SEARCH: (^.*)(?s)(\w+{2}IOANA\w+{2})(.*)

REPLACE BY: \1\2

3

1 Answer

  • Ctrl+H
  • Find what: (?:\S+ ){2}(IOANA)(?: \S+){2}
  • Replace with: $1
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

(?: # non capture group \S+ # 1 or more non space character # a space
){2} # end group, must appear twice
(IOANA) # group 1
(?: # non capture group # a space \S+ # 1 or more non space character
){2} # end group, must appear twice

I guess, here, that you means words are composed with non spaces characters.

  • If, for you, word contains only letters and digits, use [a-zA-Z0-9]+ instead of \S+.
  • If, for you, word contains only letters and soeme punctuation like ', use [a-zA-Z']+ instead of \S+.

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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