wimhek Posted May 31, 2009 Posted May 31, 2009 How can I do a string split on a delimiter longer than 1 pos ? F. i. I have a string : $a ="<href=blah di bla <href=asdsdadsda <href=........." And I want to do a stringsplit on '<href=' e.g. $b=stringsplit($a,'<href=') thnx
Bowmore Posted May 31, 2009 Posted May 31, 2009 (edited) How can I do a string split on a delimiter longer than 1 pos ?F. i. I have a string :$a ="<href=blah di bla <href=asdsdadsda <href=........."And I want to do a stringsplit on '<href='e.g.$b=stringsplit($a,'<href=')thnx$b=stringsplit($a,'<href=',1) wiil do the job_StringBetween() might also be worth checking out for what you require. Edited May 31, 2009 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
GEOSoft Posted May 31, 2009 Posted May 31, 2009 How can I do a string split on a delimiter longer than 1 pos ? F. i. I have a string : $a ="<href=blah di bla <href=asdsdadsda <href=........." And I want to do a stringsplit on '<href=' e.g. $b=stringsplit($a,'<href=') thnx $a = StringReplace($a, "<href=", "|") $b = StringSplit($a, "|") George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
unixu Posted May 31, 2009 Posted May 31, 2009 How can I do a string split on a delimiter longer than 1 pos ?F. i. I have a string :$a ="<href=blah di bla <href=asdsdadsda <href=........."And I want to do a stringsplit on '<href='e.g.$b=stringsplit($a,'<href=')thnxdepens and why you need to split = do you want to cut out the url then i would use stringinstr and stringregexp
wimhek Posted May 31, 2009 Author Posted May 31, 2009 $b=stringsplit($a,'<href=',1) wiil do the job_StringBetween() might also be worth checking out for what you require.Thank you, the _stringbetween did the job, however, how can I process the table, as I dont kow how many elements ate in the array. (With stringsplit, I get the number of elements in the first arrayline)
Bowmore Posted May 31, 2009 Posted May 31, 2009 Thank you, the _stringbetween did the job, however, how can I process the table, as I dont kow how many elements ate in the array. (With stringsplit, I get the number of elements in the first arrayline)Use Ubound. Two examples for you #include <string.au3> ;Using StringBetwen $aData = _StringBetween("<href=blah di bla <href=asdsdadsda <href=.........","ref=","<h") For $i = 0 To UBound($aData) -1 MsgBox(0,"Values", $aData[$i]) Next ;Using String split ;Note:returns "" in element 1 and "......." in last element $aData = StringSplit("<href=blah di bla <href=asdsdadsda <href=.........","<href=",1) For $i = 1 To UBound($aData) -1 MsgBox(0,"Values", $aData[$i]) Next "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Richard Robertson Posted May 31, 2009 Posted May 31, 2009 A regular expression would help too.$matches = StringRegexp($yourstring, 'href="([^"]*)"', 1)
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