Jump to content
Sign in to follow this  
lostbit

Parsing a string, where to start.

Recommended Posts

lostbit

Yah it's me again,

OK I have a script that reads from a gui a line of text; sometimes the tesxt is not

what I need, i.e. http/www something. I only want the string when it does not

have this format. The text changes sort of like adds.

I have looked at some of the examples but I do not get the aproach.

I need to get the string,

evaluate the string

if contains unwanted text, get string again,

max retry count so it does not loop.

Share this post


Link to post
Share on other sites
Richard Robertson

Please give me a list of example lines and say good or bad on them so I can fully understand what it is you need or don't need.

Share this post


Link to post
Share on other sites
BrettF

Maybe...

$url1 = "http/google.com"
$url2 = "http://www.google.com"

MsgBox (0, "", _IsValid($url1))
MsgBox (0, "", _IsValid($url2))

;Returns 1 for valid, 0 for invalid.
Func _IsValid ($url)
    Return StringRegExp ($url, "(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?")
EndFunc

Share this post


Link to post
Share on other sites
Darktan

I believe StringInSr is what you want.

StringInStr

--------------------------------------------------------------------------------

Checks if a string contains a given substring.

StringInStr ( "string", "substring" [, casesense [, occurrence [, start [, count]]]] )

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.