问题与RegEx Lookaround包含新行 [英] Issue with RegEx Lookaround where new lines are included
问题描述
好的,我试图分析类似于这样的文本块:
<$
>私人小组NAV_VE124_Click()
'在描述字段中打开图片
调用ShowPic(Me.NAV_VE124.Description)
End Sub
和正则表达式模式(?<= Private Sub)((。*?)( ?= _ Click))
似乎可以找到 NAV_VE124
$ b
,但由于某些原因(?<= \')((。*?)(?= End))
不会产生任何结果...
任何想法都将不胜感激。 b
$ b
另外,我想结合这两个搜索,所以我只抓住'如果其他条件允许,所以任何想法如何做到这一点也将是惊人的
(?< = \')((。| \s )*(?= End))
lem是多行...不知道你使用什么样的正则表达式工具,只是做一个(。| \s)*来匹配任何东西,包括换行符。如果\s不起作用,请找出与您的工具的换行符匹配的内容。
Edit: Clarification, I am using Sublime text. It appears the problem was in fact the multiline issue. Thank you all for your feedback!
Okay so I'm trying to analyze text blocks similar to this:
Private Sub NAV_VE124_Click()
'Open the picture in its description field
Call ShowPic(Me.NAV_VE124.Description)
End Sub
and the regex pattern (?<=Private Sub )((.*?)(?=_Click))
seems to work to locate NAV_VE124
and yet for some reason (?<=\')((.*?)(?=End))
Does not produce any result...
Any thoughts would be greatly appreciated.
Also, I would like to combine these two searches so that I only grab the stuff after ' if the other condition is allowed, so any thoughts on how to do that would also be phenomenal :)
(?<=\')((.|\s)*(?=End))
the problem is the multiline...not sure what regex tool your using but just do a (.|\s)* to match anything including newline. If \s doesn't work then find out what matches newline for your tool.
这篇关于问题与RegEx Lookaround包含新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!