Jump to content
Sign in to follow this  
Izebize

StringRegExp, same string more then once

Recommended Posts

Izebize

Hi!

I wrote a little script to demonstrate my problem:

#include <Array.au3>
$sString = "Blablalba" & @CRLF & _
            "Something goes here: coolstuff" & @CRLF & _
            "Blablabla" & @CRLF & _
            "Something goes here: else" & @CRLF & _
            "Blablabla"
$aSRE = StringRegExp($sString, "(?:Something goes here: ([a-z]*))+", 1)
_ArrayDisplay($aSRE)

It creates an array ["coolstuff"].

How can I make it to recognize the other string, so the result would be ["coolstuff", "else"] ?

Share this post


Link to post
Share on other sites
Malkey

Hi!

I wrote a little script to demonstrate my problem:

#include <Array.au3>
$sString = "Blablalba" & @CRLF & _
            "Something goes here: coolstuff" & @CRLF & _
            "Blablabla" & @CRLF & _
            "Something goes here: else" & @CRLF & _
            "Blablabla"
$aSRE = StringRegExp($sString, "(?:Something goes here: ([a-z]*))+", 1)
_ArrayDisplay($aSRE)

It creates an array ["coolstuff"].

How can I make it to recognize the other string, so the result would be ["coolstuff", "else"] ?

Try changing the flag parameter of StringRegExp to global matches, 3.

Share this post


Link to post
Share on other sites
Izebize

Oh, I forgot that, thanks!

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  

×

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.