[*:2urvzjq0]PhiLho enhanced the original code & included Replace, Rot13 and Rot47
[*:2urvzjq0]Titan re-wrote the function and enhanced it with Scramble, Bloat, Pattern.
Function StringMod() extracts, excludes or replaces specified characters from the String passed on to it and returns
the modified string. It can also flip a string (reversed order) or convert it into Rot13 and Rot47.
Additional functionality are detailed below.
Usage: StringMod(string, method [, param1, param2])
Downloads :String Modification: Methods with examples
Methods:
Only
Omit
Flip
Replace
Rot13
Rot47
Scramble
Bloat
Pattern[/list]Examples:
Extract the Vowels from the name "Goyyah"
StringMod("Goyyah","Only","AEIOU") returns "oa"
Extract the Consonants from the name "Goyyah"
StringMod("Goyyah","Omit","AEIOU") returns "Gyyh"
Flips "Goyyah"
StringMod("Goyyah","Flip") returns "hayyoG" [*:2urvzjq0]Credit: Thanks to Rubberduck for his function StringFlip()[/list]Replace "*^" in "^H*e*l*l*o^" with "_"
StringMod("^H*e*l*l*o^", "Replace" , "*^" , "_") returns "_H_e_l_l_o_"
Example for Validating a String into Filenamefilename = This?Is?\A:/<"Valid"File>*Name?.txt invalidFilenameCharacters=\/:*?"<>| Msgbox, % StringMod(filename, "Replace", invalidFilenameCharacters) ; This_Is_A___Valid_File__Name_.txt
Convert "HELLO" into Rot13
StringMod("Hello", "Rot13") returns "UYRRB"
Convert "HELLO" into Rot47
StringMod("Hello", "Rot47") returns "wt{{~"
Scramble the word "AUTOHOTKEY"
StringMod("AUTOHOTKEY","Scramble") will return something like "UKOTTOEAHY"
[*:2urvzjq0]Standalone version of Scramble()[*:2urvzjq0] Laszlo's CharPerm() - similar functionality - optimised
Stuff Characters before and after each character in the word "Autohotkey"
StringMod("AutoHotkey","Bloat", "{" , "}" ) returns "{A}{u}{t}{o}{H}{o}{t}{k}{e}{y}"
[*:2urvzjq0]Credit: Thanks to Laszlo for his function CharBloat()
Pattern may be used to find the Anagrammatical relationship between two words.
Pattern returns a String arranged in alphabetical order in such
a way that the number of occurences follows each letter
Pattern1 := StringMod("RACE","Pattern") ; "A1C1E1R1"
Pattern2 := StringMod("CARE","Pattern") ; "A1C1E1R1"
If Pattern1 = %Pattern2%
; evaluates to a logical true because both Pattern1 and Pattern2 share the same pattern "A1C1E1R1"
[*:2urvzjq0] Laszlo's comments/variant(s) on Pattern is here[*:2urvzjq0]Download a Demo: Anagram / Jumbled word Finder 745KB
[*:2urvzjq0]Visit Brendan's On-Line Anagram Generator [/list] [/list]
[*:2urvzjq0]PhiLho`s enhanced version of StringMod() : Download latest version.
[*:2urvzjq0]Titan`s enhanced version of StringMod() : Download latest version.[*:2urvzjq0]2006-Dec-29: A new RegEx based StringMod() has been posted here[/list][/list]