Jump to content
UBot Underground

scraping a string of text?


Recommended Posts

I've been staring ubot like an idiot for about 2 hours now stuck on a hang up.

 

Breaking it down, I have the following :

 

Open file > with a variable attached to it.

 

I want to take that variable and parse it for the file name/extension ie remove everything bolded C:\Users\name\Desktop\folder\example.txt and leave just the file name, but do so in such a way that it doesn't matter how whats in front of the file name. Anyone have a solution to this?

Link to post
Share on other sites

I would do a find by regular expression on the variable using the following regex code:

 

\\[a-zA-Z0-9]*\.[a-zA-Z0-9]*

 

Then in the next step I would do a replace on that same variable searching for \ and replacing it with $nothing.

 

That should leave you just the file name

Link to post
Share on other sites

You can combine/condense those steps with:

 

set(#file name, $replace($find regular expression($find regular expression(#file name, "\\\\[a-zA-Z0-9]*\\.[a-zA-Z0-9]*"), "\\\\[a-zA-Z0-9]*\\.[a-zA-Z0-9]*"), "\\", $nothing), "Global")

 

might be a hiccup with multi-word file names though...

 

 

http://www.ubotstudio.com/forum/public/style_emoticons/default/blink.gif

Link to post
Share on other sites

If Regex is not your game then here is an easy alternative for you:

 

Code:

add list to list(%sample, $list from text("C:\\Users\\name\\Desktop\\folder\\example.txt", "\\"), "Delete", "Global")
set(#filename, $list item(%sample, $subtract($list total(%sample), 1)), "Global")

 

Hope it helps :)

Praney

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...