Regex 正则表达式匹配行的最后一句
收到一些文字:Regex 正则表达式匹配行的最后一句,regex,Regex,收到一些文字: [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
[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
我试图匹配每行末尾的最后一句话,因此匹配如下:
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
不幸的是,我不能依赖于行的结构来符合,但我试图提取的信息应该始终是最后一句话。我尝试了很多不同的方法,但我在这里很挣扎。如果在最后一句之前还有一些关于无词字符的方法,请尝试:
[\w\s']+$
编辑:以上由m.cekiera
[\w\s']+$
给出的答案更好
](.+)$
这里有一个非常简单的解决方案:
如果您提供有关实际结构的更多详细信息,则可以对其进行优化。因此我们不能依赖于匹配最后一个括号“]”?使用正则表达式可能有一个更简单的解决方案。在不知道这是为了什么环境的情况下,我不能提出任何更具体的建议。语言?Platform?@Jazcash您可以将其更改为
\w[\w\s']+$
,以避免匹配第一个空格字符(``)