[SOLVED] delete specific character in first left in var

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

[SOLVED] delete specific character in first left in var

18 Jun 2016, 18:00

Hello,

How to deleting a specific character in first left ?

Ex:

Code: Select all

080 get 80 
Or
008 get 8
Or
ABA get BA
I tried : StringReplace
But this delete all character :/

Thank for your help
Last edited by Marvin1023 on 18 Jun 2016, 19:20, edited 1 time in total.
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: delete specific character in first left in var

18 Jun 2016, 19:00

Are you saying you want to remove all leading zeros from numbers and only the first char from strings ?
Edit: If so try this.

Code: Select all

var := "00080"
RegExMatch(var, RegExMatch(var, "^\d*$") ? "([1-9]\d+$)" : "((?<=\w)\w+$)", res)
MsgBox, % res
Please excuse my spelling I am dyslexic.
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Re: delete specific character in first left in var

18 Jun 2016, 19:19

Capn Odin wrote:Are you saying you want to remove all leading zeros from numbers and only the first char from strings ?
Edit: If so try this.

Code: Select all

var := "00080"
RegExMatch(var, RegExMatch(var, "^\d*$") ? "([1-9]\d+$)" : "((?<=\w)\w+$)", res)
MsgBox, % res
Thank you working !
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Re: [SOLVED] delete specific character in first left in var

18 Jun 2016, 19:24

Just like that !

it is possible to add a condition ?

Ex:
00000080 get 080
0080 get 080
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: [SOLVED] delete specific character in first left in var

18 Jun 2016, 19:31

Marvin1023 wrote:Just like that !

it is possible to add a condition ?

Ex:
00000080 get 080
0080 get 080
  • 080 = 80
  • 0080 = 080
  • 00080 = 080
all tree at the same time ?
Edit: I am sorry that the code have gotten ugly.

Code: Select all

var := "00080"
RegExMatch(var, RegExMatch(var, "^\d*$") ? (RegExMatch(var, "^00") ? "(0[1-9]\d+$)" : "([1-9]\d+$)") : "((?<=\w)\w+$)", res)
MsgBox, % res
Please excuse my spelling I am dyslexic.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: MSN [Bot], NinjoOnline and 210 guests