crzftx Posted May 18, 2008 Share Posted May 18, 2008 (edited) I ran "StringRegExp($string,"(\d{1,3}[.]){3}\d{1,3}[:]\d{5}",1)" on a long string with a bunch of different IPs scattered about it. I thought it would return all of the IPs of the form 000.000.000.000:00000 where the first five 000 could be 1-3 digits long, thereby capturing all of the IPs. The return is oddly a 1-index array with only "83." in it. Any help on the Regular Expression would be great! Edited May 18, 2008 by crzftx Link to comment Share on other sites More sharing options...
Siao Posted May 18, 2008 Share Posted May 18, 2008 Flag for global matching is 3, not 1. You have first octet and the dot in a group, therefore it's the only thing that gets captured. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
crzftx Posted May 18, 2008 Author Share Posted May 18, 2008 Well that did help. Thanks Siao. So... is the group always the only thing that is captured? To capture the IP would I have to do something like Global $array = StringRegExp($string,"(\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[:]\d{5})",3) How would I go about using a group without having the group alone returned? Link to comment Share on other sites More sharing options...
Siao Posted May 18, 2008 Share Posted May 18, 2008 How would I go about using a group without having the group alone returned?Non-capturing group - (?: ... ) "be smart, drink your wine" Link to comment Share on other sites More sharing options...
crzftx Posted May 18, 2008 Author Share Posted May 18, 2008 (edited) Thanks a lot! Now I can capture lists of IPs quickly. StringRegExp($string,"(?:\d{1,3}[.]){3}\d{1,3}[:]\d{5}",3) Edited May 18, 2008 by crzftx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now