Separate ending number of a string into variable with Applescript -


i wondering if it's possible detect number on end of random string. example in string: "localfile/random/1" i'd split string 1 variable number on end of string, , second variable rest of path. couldn't google anything.

any appreciated.

if can split strings around last slash:

set x "localfile/random/1" set text item delimiters "/" {(text items 1 thru -2 of x) text, last text item of x} 

both of these work if strings end numbers:

on test(x)     set c count of x     repeat 1 c         if item (c - i) of x not in items of "0123456789"             return {text 1 thru (c - i) of x, text (c - + 1) thru -1 of x}         end if     end repeat end test test("localfile/random/1")  shell script "sed -e $'s/([0-9]*)$/\\\\\\n\\\\1/' <<< " & quoted form of "localfile/random/1" set {x, y} paragraphs of result 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -