Jump to content
Sign in to follow this  
SmOke_N

StringRegExp() ...

Recommended Posts

SmOke_N

I'm trying to get the vars from a string, does anyone see why it's picking up the first var and not the 2nd one?

Local $a_Array = StringRegExp('$abc' & @CRLF & '$abcde', '(?i:\$)(.*?)(?i:\W\s)', 3)
If IsArray($a_Array) Then
    For $iCount = 0 To UBound($a_Array) - 1
        MsgBox(64, 'Info', 'Var ' & $iCount & ' = $' & $a_Array[$iCount])
    Next
EndIf
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Knight

It was only picking up the first one because the second one did not have @CRLF on the end. Your pattern required that to be on there for it find it.

I think you want this.. or something close to it atleast.

Local $a_Array = StringRegExp('$abc' & @CRLF & '$abcde', '(?i:\$)(\A*)', 3)
If IsArray($a_Array) Then
    For $iCount = 0 To UBound($a_Array) - 1
        MsgBox(64, 'Info', 'Var ' & $iCount & ' = $' & $a_Array[$iCount])
    Next
EndIf

Share this post


Link to post
Share on other sites
SmOke_N

It was only picking up the first one because the second one did not have @CRLF on the end. Your pattern required that to be on there for it find it.

I think you want this.. or something close to it atleast.

Local $a_Array = StringRegExp('$abc' & @CRLF & '$abcde', '(?i:\$)(\A*)', 3)
If IsArray($a_Array) Then
    For $iCount = 0 To UBound($a_Array) - 1
        MsgBox(64, 'Info', 'Var ' & $iCount & ' = $' & $a_Array[$iCount])
    Next
EndIf
Thanks for the reply Knight... Now this does indeed work with the example... but It's not working with FileRead() (Getting all the vars).... I'm stumped :whistle:. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
SmOke_N

Thanks again Knight, come to find out, yes, the code 1 was not correct the first time, and 2, I was parsing it incorrectly looking for duplicates.... I've fixed both... this is what I need

'(?i:\$)(\w*)'


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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.