Sign in to follow this  
Followers 0
jxn

Need help with _StringBetween

4 posts in this topic

Hi there,

I am having some trouble with _StringBetween when learning the basics. Here is the code:

#include <String.au3>

$test = "<p>This is a test</p>"
$abc = _StringBetween($test, "<p>", "</p>")

$file = FileOpen("test.txt", 1)
FileWrite($file, $abc)
FileClose($file)

I want to get the text "This is a test", and write it into test.txt file, however, the code fails to work and nothing has been written into the file. Something is wrong with _StringBetween, but I can't figure it out. Can anyone help to identify what the problem is?

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

FileWrite($file, $abc[0])

Return Value

Success: A 0 based $array[0] contains the first found string.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Great tips! Thanks bogQ. I change $abc into $abc[0], and it runs perfectly now.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Oh, one more thing, I found _StringBetween is really powerful in scraping webpages, really helps me a lot!

Edited by jxn

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