Jazcash
Jazcash

Reputation: 3314

Regex to match last sentence of a line

Got some text:

[23/07 | DEV | FARO | QC Billable | #2032] Unable to Load label 
[30/07 | QC | ROLAWN ] Selling products as a bundle 
[11/08 | EST | QC BILLABLE | #2015 ISUOG ] On Demand website looping
[05/08 |  EST | ROLAWN | Problems with 'find a stockist'
[29/07 | DEV | QUBA] Blog comments loading to error
[24/07 | FROG | EST| QC BILLABLE #2033] Carousel banner not working correctly

I'm trying to match the last sentence at the end of each line so the matches are as follows:

Unable to Load label 
Selling products as a bundle 
On Demand website looping
Problems with 'find a stockist'
Blog comments loading to error
Carousel banner not working correctly

Unfortunately, I can't depend on the structure of the line to conform, but the information I'm trying to extract should always be the last sentence. I've tried quite a few different things, but I'm struggling here.

Upvotes: 1

Views: 2213

Answers (2)

m0meni
m0meni

Reputation: 16435

Edit: The answer above by m.cekiera [\w\s']+$ is better.

](.+)$

Here's a pretty naive solution: https://regex101.com/r/yT8jJ7/1.

If you give more details about the actual structure it could be refined.

Upvotes: 1

m.cekiera
m.cekiera

Reputation: 5395

If there is also some kind on no-word character before last sentence, try with:

[\w\s']+$

DEMO

Upvotes: 2

Related Questions