s15199d
s15199d

Reputation: 7717

Regex Find Text Between Previous Period and String

Example Text: "This is the beginning. First group of words. Second plain sentence. Another set of words."

Pattern logic: Match anything between the word "sentence" and the preceding period. The match may extend multiple lines.

Desired match: " Second plain "

Note: Match should not include quotation marks.

Upvotes: 0

Views: 1981

Answers (2)

Kent
Kent

Reputation: 195209

without grouping, using look ahead (zero width)

 [^.]*(?=sentence)

Upvotes: 0

VladL
VladL

Reputation: 13043

this is pretty simple:

\.([^.]+?)sentence

the match is the first group ($1)

Upvotes: 0

Related Questions