string hacks

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

string hacks

12 Jul 2017, 15:00

I started collecting various string hacks, if anybody wants to contribute any. Cheers.

Sometimes I like to share quick (but hopefully readable) code without using custom functions.

Other issues might be two-way compatibility, to write something that can be used in an expression, a one-liner, to write a stand-alone function with no dependencies, to avoid 'Loop' because it's slow. Or I weigh up, slightly ugly/unreadable code with no dependencies, versus dependency. Or for a quick demo/tutorial script, trade-offs such as a few milliseconds drop in performance, for added script clarity or fewer lines.

Code: Select all

;'StrCount'

;count occurrences of 'ab'
MsgBox, % StrSplit("abcabcabc", "ab").Length() - 1
;count occurrences of 'abc'
MsgBox, % StrSplit("abcabcabc", "abc").Length() - 1
;count items
MsgBox, % StrSplit("abc,abc,abc", ",").Length()

;e.g. this technique is used here:
;combinations and permutations (and anagrams) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=34244&p=158874#p158874

;to use StrReplace and return a value within a single expression:
;note: division by 0 to give a blank string
vText := "abc,abc,abc"
MsgBox, % "item count: " StrReplace(vText,",","",vCount)/0 (vCount + 1)

;comparing the length of the string before and after:
vText := "abcabcabc"
MsgBox, % (StrLen(vText) - StrLen(StrReplace(vText, "abc"))) / 3
MsgBox, % StrLen(vText) - StrLen(StrReplace(vText, "abc", "__"))

vText := "abcabcabc"
vNeedle := "abc"
MsgBox, % (StrLen(vText) - StrLen(StrReplace(vText, vNeedle))) / StrLen(vNeedle)
MsgBox, % StrLen(vText) - StrLen(StrReplace(vText, vNeedle, SubStr(vNeedle, 2)))

;a theoretical StrCount function:
;MsgBox, % StrCount(vText, vNeedle)
;MsgBox, % StrCount(vText, vNeedle, vCaseSen)

;==============================

;if var in

;'if var in' (due to replaced) alternative, no RegEx escapement issues
MsgBox, % {aa:0,bb:0,cc:0}.HasKey("aa")
MsgBox, % {aa:0,bb:0,cc:0}.HasKey("dd")

MsgBox, % {aa:1,bb:1,cc:1}["aa"]
MsgBox, % {aa:1,bb:1,cc:1}["dd"]

a := "aa", b := "bb", c := "cc"
MsgBox, % {(a):0,(b):0,(c):0}.HasKey("aa")
MsgBox, % {(a):0,(b):0,(c):0}.HasKey("dd")

MsgBox, % Object("a",0,"b",0,"c",0).HasKey("a")
MsgBox, % Object("a",0,"b",0,"c",0).HasKey("d")
;MsgBox, % Object("a",0,"b",0,"c",0).HasKey("" vText)

MsgBox, % Object(StrSplit("a,,b,,c,")*).HasKey("a")
MsgBox, % Object(StrSplit("a,,b,,c,")*).HasKey("d")
;MsgBox, % Object(StrSplit("a,,b,,c,")*).HasKey("" vText)

;the same technique as here:
;convert list to simple array - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=33663
oArray := StrSplit("a,,b,,c,")
MsgBox, % Object(oArray*).HasKey("a")
MsgBox, % Object(oArray*).HasKey("d")
oArray := ""

;that method is better than this one, as no delimiter is needed
vText := "a"
MsgBox, % InStr("|a|b|c|", "|" vText "|")
vText := "d"
MsgBox, % InStr("|a|b|c|", "|" vText "|")

;==============================

;if var contains/starts/ends

;I think I need to use RegEx for if var contains/starts/ends

;==============================

;'StrRept'

;Replicate() : Repeats a string N times - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=33977
==================================================

Code: Select all

q:: ;if var in/contains/starts/ends examples
vList := "abcde,abcdex,xabcde"
Loop, Parse, vList, % ","
{
	vText := A_LoopField
	MsgBox, % (vText ~= "^(abcde|fghij|klmno)$") ;in
	MsgBox, % (vText ~= "bcd|ghi|lmn") ;contains
	MsgBox, % (vText ~= "^(abc|fgh|klm)") ;contains (starts)
	MsgBox, % (vText ~= "(cde|hij|mno)$") ;contains (ends)
}
return

w:: ;if var in/contains/starts/ends examples
vList := "abcde,abc,cde"
Loop, Parse, vList, % ","
{
	;note: any special characters in vText would have to be escaped
	vText := A_LoopField
	MsgBox, % ("abcde" ~= "^" vText "$") ;in
	MsgBox, % ("abcde" ~= vText) ;contains
	MsgBox, % ("abcde" ~= "^" vText) ;contains (starts)
	MsgBox, % ("abcde" ~= vText "$") ;contains (ends)
}
return
==================================================

[EDIT:] Some updates:

Code: Select all

q:: ;string count
vText := "_abc_abc_abc_"
MsgBox, % StrLen(RegExReplace(vText, "(a)(?=bc)|.", "$1"))
MsgBox, % Format("", StrReplace(vText, "abc", "", vCount)) vCount
return
Also:
simplest way to make a RegEx needle literal? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=30420
Last edited by jeeswg on 21 Feb 2018, 21:58, edited 3 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

27 Jul 2017, 18:27

Wish I knew about this a long time ago, I didn't know that string functions could return a number as a number, anyhow:

Code: Select all

q:: ;string to number
vHex := "A"
MsgBox, % ("0x" vHex)+1 ;blank (doesn't work)
MsgBox, % SubStr("0x" vHex, 1)+1 ;11

vText := "a1a1a1a"
MsgBox, % StrReplace(vText, "a")+1 ;112

MsgBox, % ("11")+1 ;blank (doesn't work)
MsgBox, % SubStr("11", 1)+1 ;12

MsgBox, % ("1" "1")+1 ;blank (doesn't work)
MsgBox, % SubStr("1" "1", 1)+1 ;12
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

09 Nov 2017, 11:39

Since StringSplit (text split to variables) is being removed in AHK v2, I needed a way to achieve text to variables.

Note: StrSplit (text split to array keys) will remain in AHK v2.

Code: Select all

q:: ;the new look StringSplit for AHK v2
;string split to variables 2-liner
vTemp := "a,b,c"
Loop, % vTemp0 := (oTemp := StrSplit(vTemp, ",")).Length()
	vTemp%A_Index% := oTemp[A_Index]
oTemp := ""
MsgBox, % vTemp0 " " vTemp1 " " vTemp2 " " vTemp3
return
[EDIT:] Actually, this is simpler. Oh well.

Code: Select all

w:: ;string split to variables
vTemp := "a,b,c"
Loop, Parse, vTemp, % ","
	vTemp%A_Index% := A_LoopField, vTemp0 := A_Index
MsgBox, % vTemp0 " " vTemp1 " " vTemp2 " " vTemp3
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
FanaticGuru
Posts: 1361
Joined: 30 Sep 2013, 22:25

Re: string hacks

09 Nov 2017, 12:44

jeeswg wrote:Since StringSplit (text split to variables) is being removed in AHK v2, I needed a way to achieve text to variables.

Note: StrSplit (text split to array keys) will remain in AHK v2.

Code: Select all

q:: ;the new look StringSplit for AHK v2
;string split to variables 2-liner
vTemp := "a,b,c"
Loop, % vTemp0 := (oTemp := StrSplit(vTemp, ",")).Length()
	vTemp%A_Index% := oTemp[A_Index]
oTemp := ""
MsgBox, % vTemp0 " " vTemp1 " " vTemp2 " " vTemp3
return
[EDIT:] Actually, this is simpler. Oh well.

Code: Select all

w:: ;string split to variables
vTemp := "a,b,c"
Loop, Parse, vTemp, % ","
	vTemp%A_Index% := A_LoopField, vTemp0 := A_Index
MsgBox, % vTemp0 " " vTemp1 " " vTemp2 " " vTemp3
return
I don't really see why you would want to use pseudo-array and I much prefer for over loop.

Code: Select all

; Standard Object Looping
vTemp := "a,b,c"
for key, val in StrSplit(vTemp, ",")
	MsgBox % key "`t" val

; Create Pseudo-Array 
for key, val in StrSplit(vTemp, ",")
	vTemp%key% := val, vTemp0 := key
MsgBox, % vTemp0 " " vTemp1 " " vTemp2 " " vTemp3
Your code examples are like going backwards in time but not in a cool disco way, but a phone has to be wired to the wall way.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
Helgef
Posts: 4031
Joined: 17 Jul 2016, 01:02
Contact:

Re: string hacks

09 Nov 2017, 13:52

Thanks for sharing jeeswg :wave:
Your code examples are like going backwards in time but not in a cool disco way, but a phone has to be wired to the wall way.
:lol:
However, pure string variables perform significantly better than string containing array elements in certain string operations, for example concatenation. So I'd say jeeswgs code certainly has its place :thumbup:

Cheers.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

09 Nov 2017, 14:04

Hmm, interesting FanaticGuru, you've made me realise how if you are able to use a for loop instead of Loop, you could make certain AHK v1 code that is not AHK v2 compatible, AHK v2 compatible. I'm not going to replace my code based on this, and this doesn't help with registry or file loops, but if you're desperate to convert a one-off script, which for whatever reason you'd like it to be two-way compatible, *now*, it's a possibility.
[EDIT:] Loop examples for AHK v1/v2:
conversion logic, v1 = -> v1 := -> v2, two-way compatibility - Page 5 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 92#p181692

Also, that for loop, 'cleans up' after itself, right, the object is deleted once the for loop is over.

I had a function I was checking over, and I wanted to remove StringSplit, so I needed a quick fix. I could have used StrSplit and replaced all the subsequent variable names with object references, but then you get an ugly mix of variables and object references.

My instinct is that for StrSplit/RegExMatch scenarios with a small number of output items it is better to create multiple variables and not arrays, only for certain circumstances would I prefer an array.

The pseudo-array may have been invented because a traditional array was not available. But the pseudo-array deserves some love.

Cheers for the info Helgef.
Last edited by jeeswg on 17 Nov 2017, 15:23, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
FanaticGuru
Posts: 1361
Joined: 30 Sep 2013, 22:25

Re: string hacks

09 Nov 2017, 15:26

Helgef wrote:However, pure string variables perform significantly better than string containing array elements in certain string operations, for example concatenation. So I'd say jeeswgs code certainly has its place :thumbup:
jeeswg wrote:But the pseudo-array deserves some love.
Yea, pseudo-array is another tool in the toolbox even if it is kind of buried in the bottom of my toolbox, it is still good to have if I need to dig it out.

For me clarity of code is more important than performance. I rarely run into performance problems, but I am constantly having to unravel and modify code. At some point I need to try this new fandangle v2 that is supposed to be the next generation of simpler coding.

I agree jeeswg's code has its place. Their code often has a unique prospective and sometimes helps me to see insights that I had not thought about.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

02 Dec 2017, 19:57

Get the largest integer in a list.

There's a nice string hack here, based on code by A_AhkUser, to get the largest number in a comma-separated list or ini section, it has limited use cases, since it only handles non-negative integers (positive integers or 0), but the idea behind the hack is great. I guess it's more of a 'maths hack' (aka 'math hack') than a string hack.
Ini read and output the Key name that has largest amount - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 41#p186041
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

02 Dec 2017, 20:07

Sort by the last column. I.e. sort by the text that follows (the last instance of) a specific string.

I haven't seen anything quite like this before on the forums, but it's reasonably likely that someone would have used Sort and \, which sorts files by name, ignoring anything before the last backslash, but using a delimiter other than \ (by temporarily replacing \ with an unused character, and replacing a delimiter string with \).

Here are two examples, to sort an ini section by the values (i.e. key=value), and to sort text by the nth column (although note: anything in subsequent columns can affect the sort, i.e. sort by 'the nth column and anything after it').

Unfortunately this method cannot be used to sort numerically.
Sort
https://autohotkey.com/docs/commands/Sort.htm
Note: Options N and P are ignored when the backslash option is present.
Although come to think of it, why not? I suppose it could have been implemented.

Code: Select all

q:: ;sort by text after =
vSep := "="
vText := " ;continuation section
(
e=3
q=1
w=2
)"
MsgBox, % vText
vUnused := Chr(1)
vText := StrReplace(vText, "\", vUnused)
vText := StrReplace(vText, vSep, "\")
Sort, vText, \
vText := StrReplace(vText, "\", vSep)
vText := StrReplace(vText, vUnused, "\")
MsgBox, % vText
return

w:: ;sort by text in (or after) the 3rd column
vSep := " "
vRx := "m`n)^[^ ]* [^ ]*\K "
vText := " ;continuation section
(
a a q a
b b w b
c c e c
)"
MsgBox, % vText
vUnused := Chr(1)
vText := StrReplace(vText, "\", vUnused)
vText := RegExReplace(vText, vRx, "\")
MsgBox, % vText
Sort, vText, \
vText := StrReplace(vText, "\", vSep)
vText := StrReplace(vText, vUnused, "\")
MsgBox, % vText
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

21 Feb 2018, 22:22

Alphabetising strings using arrays instead of the Sort command (with the F option and a custom function).

Code: Select all

;RegExReplace line taken from:
;jeeswg's RegEx tutorial (RegExMatch, RegExReplace) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=7&t=28031

r:: ;AutoHotkey uses unstable sorts by default at present
;it can unexpectedly change the order of characters
vText := "aaAaa"
MsgBox, % vText
vText := RegExReplace(vText, "(?<=.)(?=.)", "_")
Sort, vText, D_
vText := StrReplace(vText, "_")
MsgBox, % vText ;aAaaa ;unexpected change in order

vText := "aaAaa"
MsgBox, % vText
vText := RegExReplace(vText, "(?<=.)(?=.)", "_")
Sort, vText, D_ F SortStable
vText := StrReplace(vText, "_")
MsgBox, % vText ;aaAaa ;unchanged
return

SortStable(vTextA, vTextB, vOffset) ;for use with AHK's Sort command
{
	vRet := (vTextA "") > (vTextB) ? 1 : (vTextA "") < (vTextB) ? -1 : -vOffset
	return vRet
}

q:: ;alphabetise string (case-insensitive stable sort)
vText := "abcdeABCDEabcdeABCDE"
oArray := []
Loop, Parse, vText
{
	vOrd := Ord(Format("{:U}", A_LoopField))
	oArray[vOrd] .= A_LoopField
}
vOutput := ""
for _, vValue in oArray
	vOutput .= vValue
MsgBox, % vOutput ;aAaAbBbBcCcCdDdDeEeE
return

w:: ;alphabetise string (case-insensitive groups of characters, case-sensitive sort applied to characters within each group)
vText := "abcdeABCDEabcdeABCDE"
oArray := []
Loop, Parse, vText
{
	vOrd2 := Ord(A_LoopField)
	vOrd := Ord(Format("{:U}", A_LoopField))
	vNum := (vOrd2 > vOrd) ? 2 : (vOrd2 < vOrd) ? 0 : 1
	vNum2 := vOrd vNum ;Unicode character number followed by 0/1/2
	oArray[vNum2 + 0] .= A_LoopField
}
vOutput := ""
for _, vValue in oArray
	vOutput .= vValue
MsgBox, % vOutput ;AAaaBBbbCCccDDddEEee
return

e:: ;Unicode characters sorted alphabetically as upper/lower case
;a case-insensitive sort effectively converts each character to upper case or lower case, and then does a case-sensitive comparison
vText := ""
Loop, 127
;Loop, 65535
	vText .= Chr(A_Index)
oArrayU := [], oArrayL := []
Loop, Parse, vText
{
	vOrdU := Ord(Format("{:U}", A_LoopField))
	vOrdL := Ord(Format("{:L}", A_LoopField))
	oArrayU[vOrdU] .= A_LoopField
	oArrayL[vOrdL] .= A_LoopField
}
vOutputU := ""
for _, vValue in oArrayU
	vOutputU .= vValue
vOutputL := ""
for _, vValue in oArrayL
	vOutputL .= vValue
;there were no examples of more than 2 unicode characters
;with the same ord value when case converted
;for _, vValue in oArrayL
;	if (StrLen(vValue) > 2)
;		MsgBox, % vValue
;Clipboard := vOutputU "`r`n`r`n" vOutputL
MsgBox, % vOutputU "`r`n`r`n" vOutputL
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

27 Mar 2018, 02:34

- I've been trying to remove dependencies between function libraries. E.g. Gen (completely stand-alone, core functions that perhaps ought to be part of AutoHotkey), Dates/Maths/Objects/SortFilters/Text (stand-alone apart from any dependencies on Gen).
- I had a sort filter that sorted a list based on the case of the string. I wanted to remove the dependency by the SortFilters library on the Text library, so I wanted a 'few-liner' if possible to replace the function call. Here's what I came up with:

Code: Select all

q:: ;string get case
vList := "hello,Hello,HELLO,HeLLo,"
vOutput := ""
Loop, Parse, vList, % ","
	vOutput .= JEE_StrGetCase(A_LoopField) "`t" A_LoopField "`r`n"
vOutput .= "`r`n"
Loop, Parse, vList, % ","
	vOutput .= JEE_StrGetCaseAlt(A_LoopField) "`t" A_LoopField "`r`n"
MsgBox, % vOutput
return

JEE_StrGetCase(ByRef vText)
{
	if (vText = "")
		return "Z"
	else if (vText == Format("{:L}", vText))
		return "L"
	else if (vText == Format("{:T}", vText))
		return "T"
	else if (vText == Format("{:U}", vText))
		return "U"
	else
		return "X"
}

JEE_StrGetCaseAlt(ByRef vText)
{
	static vList := "2,:L,:T,:U,:X"
	Loop, Parse, vList, % ","
		if (vText == Format("{" A_LoopField "}", vText,, vCase := SubStr(A_LoopField "Z", 2, 1)))
			break
	return vCase
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

14 May 2019, 14:20

- I always wanted it, so that, if you used a blank string for the Length parameter with SubStr, it would be equivalent to omitting the parameter. Well ...

Code: Select all

vNum := 3
MsgBox, % SubStr("abcdef", 1, (vNum=""?[]:[vNum])*)
vNum := ""
MsgBox, % SubStr("abcdef", 1, (vNum=""?[]:[vNum])*)

vNum := 3
MsgBox, % SubStr("abcdef", 1, StrSplit(vNum, "")*)
vNum := ""
MsgBox, % SubStr("abcdef", 1, StrSplit(vNum, "")*)
return
- Apparently, I'd jotted down the first approach on 6 Oct 2018, but the StrSplit approach, which is easier to remember, was yesterday.
- And I'd mentioned some of the logic, before that, here:
Nothing. - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=55250&p=237561#p237561
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
carno
Posts: 207
Joined: 20 Jun 2014, 16:48

Re: string hacks

25 May 2019, 15:28

Just discovered this great thread. Very helpful :)
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string hacks

07 Sep 2019, 16:10

New addition:
sort a string's characters by using qsort - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=67741

Thanks carno. :)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
SKAN
Posts: 385
Joined: 29 Sep 2013, 16:58

Re: string hacks

11 Sep 2019, 06:49

Spoiler



Awesome! Thanks.

BTW, I would use Round() to concatenate strings as number. (REF: Your post)
User avatar
SpeedMaster
Posts: 355
Joined: 12 Nov 2016, 16:09

Re: string hacks

03 Oct 2019, 16:34

String hack game:
You are a prisoner who managed to steal a key but you don't remember where you put it. Find the key to escape!

:!: the key may be difficult to find but if you look carefully you will find it.

Code: Select all

; String Hack game
; by Speedmaster
; Use cursor keys to move the player "@"
; Find the hidden key "K" to open the door "+"
; Press space key to try again

#SingleInstance force
gui, font, s12 cwhite, terminal
var:="             `n#############`n#o  x    ==)#`n#  xxhxx    #`n#    x      #`n#   xx xx x #`n#          @#`n######+######`n`nFind the hidden key (k) `nto open the door (+) `nGood Luck!`n"
gui, add, text,  vtxt center, % var
gui, color, black
gui, show
w:="(.{" instr(var, "`n")-1 "})", h:=regexmatch(var,"#\v\v")+1, print(var)
left::var:=substr(var,1,h),var:=regexreplace(var,"(.+)(#)(@)(.+)(\v)","$1$2$3$4$5$5A thick, damp wall."),var:=regexreplace(var,"(.+)(o)(@)(.+)(\v)","$1$2$3$4$5$5This toilet is a delight for flies!"),var:=regexreplace(var," (h)@", "[email protected] "),var:=regexreplace(var," (x|k)@", "[email protected] "),var:=strreplace(var," @", "@ "), Print(var)
right::var:=substr(var,1,h),var:=regexreplace(var,"(.+)(@)(#)(.+)(\v)","$1$2$3$4$5$5You push the wall, but it doesn't move."),var:=regexreplace(var,"@(x|k|h) ", " @$1"),var:=strreplace(var,"@ ", " @"), Print(var)
up::var:=substr(var,1,h),var:=regexreplace(var,"(#)" w "(@)(.+)(\v)","$1$2$3$4$5$5This wall has taken your wife's place in bed now."),var:=regexreplace(var,"(o)" w "(@)(.+)(\v)","$1$2$3$4$5$5It's not Escobar's toilet.You have a sudden urge to puke."),var:=regexreplace(var,"(=|\))" w "(@)(.+)(\v)","$1$2$3$4$5$5This is your cozy stone bed. Don't waste your time. Find the key!"),var:=regexreplace(var, "( )" w "(x|k|h)" w "(@)","$3$2$5$4$1"),var:=regexreplace(var, "( )" w "(@)","$3$2$1"), Print(var)
down::var:=substr(var,1,h),var:=regexreplace(var,"(@)" w "(#)(.+)(\v)","$1$2$3$4$5$5Don't expect to dig a tunel here, it's impossible."),var:=regexreplace(var,"(@)" w "(\+)(.+)(\v)","$1$2$3$4$5$5The guards have done their job, the door is locked."),var:=(regexreplace(var,"(.+)(####)(@)(####)(.+)(\v)","$1$2 $4$5$6$6Congratulation!`nYou escaped from jail.")) ,      var:=regexreplace(var, "(@)" w "(-)"," $2$1"),var:=regexreplace(var, "(@)" w "(k)" w "(\+)"," $2$1$4-"),var:=regexreplace(var, "(@)" w "(h)" w "( )","$5$2$1$4k"),var:=regexreplace(var, "(@)" w "(x|k|h)" w "( )","$5$2$1$4$3"),  var:=regexreplace(var, "(@)" w "( )","$3$2$1"), Print(var)
~space::reload
print(var){ 
global h
if (f:=regexmatch(var, "h") < h)
	guicontrol,,txt, % buffer:=strreplace(var, "h", "x",,1)
else
	guicontrol,,txt, % var
}
guiclose:
ExitApp
return
Have fun 8-)
Last edited by SpeedMaster on 26 Oct 2019, 16:23, edited 1 time in total.
User avatar
boiler
Posts: 3179
Joined: 21 Dec 2014, 02:44

Re: string hacks

03 Oct 2019, 18:23

SpeedMaster wrote:
03 Oct 2019, 16:34
String hack game:
Have fun 8-)
:bravo:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 56 guests