Sublime Forum

Regex - Match everything after this word

#1

hello, I want to match (delete) everything after a word I chosen.

exemple:

text_1

bla bla WORD

text_2

text_3

I made a Regex, but is not working:

(?s)((^.*)(WORD))

Can anyone help me?

0 Likes

Upper character after specific
#2

(?<=WORD).*$ or just

  1. select all WORD (maybe alt+f3 or search and find)
  2. press → and then shift+end to select all text after
0 Likes

#3

yes, works fine, but this regex you gave me will match everything only until the next line, only from the paragraph.

But how can I match (delete) everything after the WORD ?

0 Likes

#4

How about (?<=WORD)(?s)(.*$) and replace with nothing

0 Likes

#5

THANKS,works fine !

0 Likes

#6

one question, what exactly does “?” and “s” from (?s)

0 Likes

#7

(?s) is a setting for the regexp to make . also match an end of line, and $ match the end of file instead.

1 Like

#8

this will delete everything after WORD and also the line that contains “WORD”

^.*(?<=(WORD))(?s)(.*$)

0 Likes