Jump to content

String Management [Another problem encountered]


Recommended Posts

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

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.
Link to comment
Share on other sites

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

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