String Things - Stand-alone string manipulation functions

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

String Things - Stand-alone string manipulation functions

01 Oct 2013, 09:19

String Things v2.6
A collection of commonly needed functions for working with strings and arrays.

There are better descriptions and an example for each function in the comments of the code.
Download

Code: Select all

No functions rely on eachother. You may simply copy/paste the ones you want or need.
.-==================================================================-.
|Function                                                            |
|====================================================================|
| st_count(string [, searchFor])                                     |
| st_insert(insert, into [, pos])                                    |
| st_delete(string [, start, length])                                |
| st_overwrite(overwrite, into [, pos])                              |
| st_format(string, param1, param2, param3, ...)                     |
| st_word(string [, wordNu, Delim, temp])                            |
| st_subString(string, searchFor [, direction, instance, searchFor2])|
| st_jumble(Text[, Weight, Delim , Omit])                            |
|                                                                    |
| st_lineWrap(string [, column, indent])                             |
| st_wordWrap(string [, column, indent])                             |
| st_readLine(string, line [, delim, exclude])                       |
| st_deleteLine(string, line [, delim, exclude])                     |
| st_insertLine(insert, into, line [, delim, exclude])               |
|                                                                    |
| st_flip(string)                                                    |
| st_setCase(string [, case])                                        |
| st_contains(mixed [, lookFor*])                                    |
| st_removeDuplicates(string [, delim])                              |
| st_pad(string [, left, right, LCount, RCount])                     |
|                                                                    |
| st_group(string, size, separator [, perLine, startFromFront])      |
| st_columnize(data [, delim, justify, pad, colsep])                 |
| st_center(text [, fill, symFIll, delim, exclude])                  |
| st_right(text [, fill, delim, exclude])                            |
|----------------------------------------------------------------    |
|array stuff:                                                        |
|   st_split(string [, delim, exclude])                              |
|   st_glue(array [, delim])                                         |
|   st_printArr(array [, depth])                                     |
|   st_countArr(array [, depth])                                     |
|   st_randomArr(array [, min, max, timeout])                        |
'-==================================================================-'
Log:
Spoiler
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

27 Dec 2013, 15:29

added st_columnize(data [, delim, justify, pad, colsep]) Screenshot
afterlemon updated st_substring()
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

28 Dec 2013, 11:43

2.4
added st_center()
added st_right()

They are simple justification functions, no fancy bells-and-whistles.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

02 Jan 2014, 12:57

2.5
Nameless-exe fixed, shorted and optimized st_jumble()!

Edit:
I just undid his changes. they were flawed :P instead I fixed a minor bug with the weight grouping.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

07 Mar 2014, 11:09

Thanks guys! :D
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: String Things - Stand-alone string manipulation function

07 Mar 2014, 18:34

download link NOT working... :cry:
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: String Things - Stand-alone string manipulation function

07 Mar 2014, 18:38

Guest10 wrote:download link NOT working... :cry:
Right-click Link and Save as... ???
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

08 Mar 2014, 10:34

Works for me. Even a normal click. Was probably just some downtime.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: String Things - Stand-alone string manipulation function

08 Mar 2014, 14:10

it always says, "Problem loading page"
The connection has timed out

The server at tidbit.3owl.com is taking too long to respond.

The site could be temporarily unavailable or too busy. Try again in a few
moments.
If you are unable to load any pages, check your computer's network
connection.
If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: String Things - Stand-alone string manipulation function

10 Mar 2014, 08:13

Working for me right now : 14:13 CET
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: String Things - Stand-alone string manipulation function

27 May 2014, 20:04

Code: Select all

sprintf(msg, vargs*) {
    for each, varg in vargs
    StringReplace,msg,msg,`%s, % varg ;msg:=RegExReplace(msg,"i)`%.",varg)
    return msg
}

mystring := sprintf("Hello %s!","joedf")
? :D
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: String Things - Stand-alone string manipulation function

27 May 2014, 21:32

tried again to download. looks like i have to sign up. do i have to sign up to upload this script? :lol:
Verdlin
Posts: 63
Joined: 04 Oct 2013, 08:55
Contact:

Re: String Things - Stand-alone string manipulation function

28 May 2014, 04:42

Thanks, Joe. It's actually slightly different than that.

Code: Select all

{
	Msgbox % st_Concat("|", 1, 2, 3, 4,5 ,6)
	return
}

st_Concat(delim, as*)
{
	for k, v in as
		s .= v . delim
	return s
}
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

28 May 2014, 09:32

joedf: sprintf already exists in ST :D st_format(). I think I went off the PHP name, can't remember.
Verdlin: Will add that!

There will be an update sooner or later. I've made some other minor changes aswell.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: String Things - Stand-alone string manipulation function

28 May 2014, 11:28

Verdlin wrote:Thanks, Joe. It's actually slightly different than that.

Code: Select all

{
	Msgbox % st_Concat("|", 1, 2, 3, 4,5 ,6)
	return
}

st_Concat(delim, as*)
{
	for k, v in as
		s .= v . delim
	return s
}

using those braces for the auto-execute section is unnecessary

User avatar
AfterLemon
Posts: 85
Joined: 30 Sep 2013, 14:27
Location: Ohio, USA

Re: String Things - Stand-alone string manipulation function

28 May 2014, 11:47

Verdlin wrote:I would find a st_Concat(delim, s*...) function quite useful.
I'm not sure that's more than a few characters you might be saving. Obviously it could be done, but it's not even something that's easier done in a function than just with a single command.

Data:="a,b,c,d,e,f,g,h",Data:=ST_Concat("|",Data*)
vs
Data:="a,b,c,d,e,f,g,h"
StringReplace,Data,Data,`,,|,1
HOME: Windows 11 Pro | AMD Ryzen 7 5800X 8-Core @ 4.50GHZ | 64GB RAM
MOBILE: Samsung Galaxy Note 10+

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: gwarble and 108 guests