且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

问题与RegEx Lookaround包含新行

更新时间:2023-12-03 21:10:04

 (?< = \')((。| \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.