Function to eliminate unwanted spaces and numbers

Get help with using AutoHotkey and its commands and hotkeys
kwfine
Posts: 16
Joined: 26 Nov 2015, 06:46

Function to eliminate unwanted spaces and numbers

21 Oct 2016, 15:02

Hi all,

I am looking for a built-in function in AHK to help me eliminate some specifc characters (e.g. numbers, spaces, underscrope) in Clipboard.
For example, I have copied some content like this:

Code: Select all

clipboard := 1 2 3 4 Hello world    __ 4 3 2 1
I want to have this as output:
Hello world

I am a new user of AHK.
Can you help me please?

Thank you
Kitty
User avatar
evilC
Posts: 4765
Joined: 27 Feb 2014, 12:30

Re: Function to eliminate unwanted spaces and numbers

21 Oct 2016, 15:08

RegexMatch()
StrSplit
either of those would probably do.

Code: Select all

str := "1 2 3 4 Hello world    __ 4 3 2 1"
RegexMatch(str, "1 2 3 4 (.+) __ 4 3 2 1", out)
msgbox % out1
Regexes are a little daunting at first, but well worth learning. Pretty much any language can use regexes, so it's a transferrable skill
Last edited by evilC on 21 Oct 2016, 15:10, edited 1 time in total.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Function to eliminate unwanted spaces and numbers

21 Oct 2016, 15:09

Hi, :)
try this:

Code: Select all

var := "1 2 3 4 Hello world    __ 4 3 2 1"
var := Trim(var, A_Space A_Tab "1234567890_")
MsgBox, % var

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, Rohwedder and 87 guests