Jump to content

String Split


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!"

Link to comment
Share on other sites

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

depens and why you need to split = do you want to cut out the url then i would use stringinstr and stringregexp

Link to comment
Share on other sites

$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)

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...