Jump to content
Sign in to follow this  

String Split Problem

Recommended Posts


I was trying to get source code of a site & split string using a keyword and what i want is text between two of those keyword . Example , site source has some code in which there are exactly two "<somekeyword>" , i want is text between these two , <somekeyword>sometext<somekeyword> , so i want here 'sometext' . Here's my code for it -

;Get Site Source Code
$httpObj = ObjCreate("winhttp.winhttprequest.5.1")
$HTMLSource = $httpObj.Responsetext
;Now split using keyword
$parsed=StringSplit ( $HTMLSource, "<somekeyword>" ,0 )
$script=$parsed[1] ; I think i should get required here but i get rubbish value like tml>
<9059<!DOCTYPE <!DOCTYPE  or something!

But it gives absturd value !

My version is v3 & source code can be as large as 50Kb. Please Help fast :|

Edited by Blankperson2

Share this post

Link to post
Share on other sites

Hi, Blankperson2. How about providing us with the URL, or an example of the page source, so we can see what you're trying to accomplish? Otherwise we're just guessing :)

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
Share on other sites

@JLogano13 , never mind URL , i replaced that with a normal string instead like "<rubbish>fds<key>i want this text<key>lhglids" and split it via "<key>" and printed 2nd element but still gives rubbish value !

And when i replace "<key>" with a single character , bingo , it works !!!

Share this post

Link to post
Share on other sites

I haven't really checked your code deeply, but are you aware of what the parameter of '1' for the StringSplit command does?

That might be your problem, if your keyword is longer than a single character?

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.


What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)


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