Sign in to follow this  
Followers 0
Mulder

Regexp (Return array of global matches) return some empty index

2 posts in this topic

Lets say i have a text between " or '

test='test' test2="test2" test3='test3' test4="test4"

and i want exactly this text only

using regexp ("[^"]*")|('[^']*')

msgbox(0,"","("&Chr(34)&"[^"&Chr(34)&"]*"&Chr(34)&")|('[^']*')")
$tmp = StringRegExp( "test='test' " & 'test2="test2" ' & "test3='test3' " & 'test4="test4" ', "("&Chr(34)&"[^"&Chr(34)&"]*"&Chr(34)&")|('[^']*')", 3 )
for $loop=0 to UBound($tmp)-1
     msgbox(  0,"", "index=" & $loop & " [" & $tmp[$loop] & "]")
next

Return is:

index=0 []

index=1 ['test1']

index=2 ["test2"]

index=3 []

index=4 ['test3']

index=5 ["test4"]

if i use

regexp ('[^']*')|("[^"]*")

index=0 ['test1']

index=1 []

index=2 ["test2"]

index=3 ['test3']

index=4 []

index=5 ["test4"]

@ http://gskinner.com/RegExr/ and http://myregexp.com/

i've made a quick test

Am i wrong?

thx

Share this post


Link to post
Share on other sites



Change your pattern: "("&Chr(34)&"[^"&Chr(34)&"]*"&Chr(34)&"|'[^']*')"

You've had 2 brackets too much. So it gives also empty results.


Best Regards BugFix  

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