Jump to content
Sign in to follow this  
willichan

matching spanned lines with RegEx

Recommended Posts

willichan

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
willichan

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.