SHOW:
|
|
- or go back to the newest paste.
1 | myString := "S523.WW.E.SIMA" | |
2 | ||
3 | ; 1) Split it into the dot-separated parts, | |
4 | ; then join it again excluding the last part | |
5 | parts := StrSplit(myString, ".") | |
6 | newString := "" | |
7 | Loop % parts.MaxIndex() - 1 | |
8 | { | |
9 | if(StrLen(newString)) { | |
10 | newString .= "." | |
11 | } | |
12 | newString .= parts[A_Index] | |
13 | } | |
14 | msgbox % newString | |
15 | ||
16 | ; 2) RegExMatch to extract everything up until the last dot | |
17 | RegExMatch(myString, "(.*)\.", newString) | |
18 | msgbox % newString1 | |
19 | ||
20 | ; 3) RegExReplace to remove everything, starting with the last dot | |
21 | - | newString := RegExReplace(myString, "\.[^.]+$", "") |
21 | + | newString := RegExReplace(myString, "\.[^\.]+$", "") |
22 | msgbox % newString |