parsing text

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sbrady19
Posts: 338
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

parsing text

Post by sbrady19 » 31 Jan 2023, 18:39

I have a text box for user input
user enters "ATP999 Bon Bon"
I need to format the text to this: ATP999%Bon%Bon

here is what I have so far:

Code: Select all

the_letters = abcdefghijklmnopqrstuvwxyz

;make ATP999 Bon Bon to this:  ATP999%Bon%Bon
loop, parse, UserInput
{
if %A_loopfield% in the_letters
new_name=new_name A_loopfield
else
new_name=new_name % ; ERROR HERE
}
msgbox %newname%
Little help please, thank you very much.
Last edited by sbrady19 on 31 Jan 2023, 18:58, edited 2 times in total.

User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: parsing text

Post by mikeyww » 31 Jan 2023, 18:42

Hi,

Use :arrow: StrReplace.

sbrady19
Posts: 338
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: parsing text

Post by sbrady19 » 31 Jan 2023, 19:25

figured it out

;make ATP999 Bon Bon to this: ATP999%Bon%Bon%20LIP
newname := StrReplace(UserInput, " ", "%20") ;replace spaces with %20 so the filename is a valid link. Priceless

User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: parsing text

Post by mikeyww » 31 Jan 2023, 19:29

You can use teadrinker's solution for a more generalizable approach. https://www.autohotkey.com/boards/viewtopic.php?f=76&t=84825

Post Reply

Return to “Ask for Help (v1)”