Jump to content
Sign in to follow this  
Yata

String Management [Another problem encountered]

Recommended Posts

Yata

I had an idea for a program that when a user inputed a URL from deviantART into an input box, it would trim the URL of useless parts and create a thumb code [similar to bbcode]. All parts of the URL except the bolded are useless in this situation:

http://username.deviantart.com/art/art-name-82878556

The problem is I can't just use StringLeft because the amount of numbers can vary. What I need is a way to evaluate the URL from right to left and stop when it hits the last number in the sequence.

I can figure out the rest of it myself, I just need some help getting the right part of the url.

So in simple terms I need to extract the last sequence of numbers which amount can vary, from a URL.

Can anyone please help?

Edited by Yata

Share this post


Link to post
Share on other sites
AdmiralAlkex

Edit:

I just noticed all the URLs have a - right before the first number. Could that be used in some way?

You could use StringInStr() or StringRegExp() to find the right position and then StringLen() and StringRight() to get the numbers.

Share this post


Link to post
Share on other sites
Xandl

Hello,

just the numbers, like this?

$s='http://username.deviantart.com/art/art-name-82878556'

$a = StringRegExp($s,'.+-(\d+)',3)
If Not @error Then
    ConsoleWrite($a[0])
EndIf

ciao

Xandl

Share this post


Link to post
Share on other sites
jvnorris

Also if the "-" is an indicator or active part of the address you can just use that as the delimiter and cut from there

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.