Nataraki
Nataraki

Reputation: 97

Regex captures all char including char of the succeeding line until a word

I am trying to get all characters starting from the first line including characters of the succeeding line until I a word EOL

Example:

chars here
    chars here
    chars here
EOL

Expected output

chars here
    chars here
    chars here

Upvotes: 0

Views: 47

Answers (1)

Amit Joki
Amit Joki

Reputation: 59282

You can use the regex

/.*(?=EOL)/s

DEMO If you don't have the support for s flag, then /[\s\S]*(?=EOL)/ would work. If you don't have the lookahead support as well, then (.*)EOL would work, with the wanted text in Group 1.

Upvotes: 1

Related Questions