Amine
Amine

Reputation: 941

How to get everything before and after specific sentence?

I have a long text and I'm trying to get it to match all except a certain sentence (Settlement Approval Rule), I have 2 patterns:

.+?(?=Settlement Approval Rule)
(?<=Settlement Approval Rule).*

First one matches everything before the sentence Second one matches everything after it. I'm looking to combine both patterns into one so I can select everything in the long text to match that isn't equal to the given sentence.

Edit: I'm using PDFUtil and I'm not expected to add or remove any code, I'm only expected to provide the Regex pattern that matches everything except "Settlement Approval Rule" so it can be used to exclude everything except the given sentence and compare two PDF files to check if they both contain the given sentence.

Thanks

Upvotes: 1

Views: 31

Answers (1)

Igor Rivin
Igor Rivin

Reputation: 4864

I don't know what language's regex library you are using, but you want to replace your magic string with "". And to do that, in python, for example, you use re.sub() as described in the accepted answer here. In other languages it might be replace (as in Oracle SQL, or C#)

Upvotes: 1

Related Questions