Sign in to follow this  
Followers 0
SmOke_N

StringRegExp() ...

4 posts in this topic

#1 ·  Posted (edited)

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



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

#3 ·  Posted (edited)

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

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  
Followers 0