Hi,
I’m attempting to create an applescript that will remove spaces and other special characters, except if that space comes after a comma. I’m attempting to take a list of keywords and make it a list of hashtags.
Some examples.
My name is Bob becomes MynameisBob
My-name-is-Bob becomes MynameisBob
My_name_is_Bob becomes MynameisBob
My@name$is*Bob becomes MynameisBob
But
My, name, is, Bob, remains My, name, is, Bob,
My, name is, Bob, becomes My, nameis, Bob,
My name is, Bob, becomes Mynameis, Bob,
What I have so far…
set thefile to "street, New York, Winston-Salem, USA" as Unicode text
findAndReplace(", ", " #", thefile)
on findAndReplace(tofind, toreplace, TheString)
set ditd to text item delimiters
set text item delimiters to tofind
set textItems to text items of TheString
set text item delimiters to toreplace
if (class of TheString is string) then
set res to textItems as string
else -- if (class of TheString is Unicode text) then
set res to textItems as Unicode text
end if
set text item delimiters to ditd
return "#" & res
end findAndReplace
The result is: “#street #New York #Winston-Salem #USA”
I need New York to read NewYork
I need Winston-Salem to read WinstonSalem
Ideas? Suggestions?
Thanks.
Model: MacBook
Browser: Safari 537.36
Operating System: Mac OS X (10.8)