Sign in to follow this  
Followers 0
willichan

matching spanned lines with RegEx

3 posts in this topic

Is there a way to tell AutoIt to let .* match characters that span multiple lines?

For example:

$sTheData = "<tag1>" & @CRLF & _
        "<tag2>" & @CRLF & _
        "# some stuff here" & @CRLF & _
        "</tag2>" & @CRLF & _
        "<tag3>" & @CRLF & _
        "# some more stuff here" & @CRLF & _
        "</tag3>" & @CRLF & _
        "</tag1>"
MsgBox(0,"Regular Expressions Test", StringRegExpReplace( $sTheData, "<tag2>.*</tag2>", ""))

This should strip out tag2 and all of its contents. But, since <tag2> and </tag2> are not on the same line, this does not work, because the .* stops matching at the CR or LF characters.

Any suggestions?

Share this post


Link to post
Share on other sites



You can add "(?s)" to the beginning of your RegExp pattern.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0