Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry in advance for the large PR
This is the new PR to add more string stocks since the old one went stale and then got closed.
Below is a list of every single useful string function I could find across other common languages (mainly JS and python), as well as a handful of functions I have used in my own projects that I think are useful. I've also added explanations where necessary but they're pretty self-explanatory.
This list is more of a starting point--I asked in the discord a while ago but never got a clear answer as to which are useful and which aren't. So I'm throwing them all at you and you can dissect which ones should stay and what should be added.
Important Note: Apart from a few, these functions are largely untested and probably not optimized well yet.
They are almost certainly buggy and need proper tests written. But I'd rather not write tests (or docstrings) for functions we're not even gonna keep so one step at a time.
I have also commented with
<<<<<<<<<<<<<<<<<<<<<<<<<<<
in places where I have questions that need answering.Function List
Rewritten Funcs from old PR
IsStringInteger
-- Is a string an integer (i.e. supported by StringToIntEx)IsStringDecimal
-- Is a string a decimal (i.e. supported by StringToFloatEx)StringToLower
StringToUpper
Identifying
IsStringUpper
-- Is string all uppercase (optionally require no whitespace)IsStringLower
-- Is string all lowercase (optionally require no whitespace)IsStringTitle
-- Is String In TitlecaseIsStringASCII
-- Does string only use valid ASCII charactersIsStringUTF8
-- Does string use any non-ASCII characters (valid or not)IsStringAlpha
-- Is string all alphabet characters (optionally require no whitespace)IsStringAlphaNumeric
IsCharAlphaNumeric
IsCharHex
IsStringHex
-- Is string all hex characters (optionally require no whitespace)IsCharVisible
-- Is a character visible when printed--no control chars, optionally allow whitespaceIsStringVisible
IsStringWhitespace
-- Is string all whitespaceStringEndsWith
StringStartsWith
Cleaning
TrimStringEx
-- Trim start/end of string but specify which characters to remove (as a string/charset)TrimStringLeft
-- Trim whitespace from left of string (see TODO)TrimStringRight
TrimStringSuffix
-- Trim an exact suffix from the string (if it exists)TrimStringPrefix
FilterString
-- Removes all characters matching charset from stringNormalizeString
-- Trim whitespace, strip quotes and force to lowercase. Useful for sanitizing string comparisons.TruncateString
-- Truncate and add trailing...
to indicate text was clipped.Mutation
StringToTitle
-- To Title CaseStringLeftPad
-- Add padding characters to the left of a stringStringRightPad
StringCenterPad
StringRepeat
-- Fill a buffer with a repetition of a string (optionally truncate)Misc
CharAt
-- Ok this one needs a demo:strncopy
-- strcopy with a length parameter.StringToIntStrict
-- StringToIntEx, but fails if string is not EXACTLY a valid and convertible numberStringToFloatStrict
ExplodeStringToList
-- Separate a delimited string to an ArrayListSubstringToInt
-- StringToInt but with a length param, allowing it to specify a substring.SubstringToIntEx
SubstringToFloat
SubstringToFloatEx
SubstringCount
-- Count substrings in string.TODO
Some concerns I have
strlen
andstrcopy
instead of doing things the harder way (since i'm dumb)