-
Notifications
You must be signed in to change notification settings - Fork 72
/
class_StringHelper.ahk
75 lines (69 loc) · 1.01 KB
/
class_StringHelper.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Class StringHelper
{
IsValidName(Name)
{
if(Name ="")
{
return false
}
pos := 1
c := SubStr(Name, pos ,1)
if(InStr("abcdefghijklmnopqrstuvwxyz_", c, false))
{
while(c)
{
if(!InStr("01234567890abcdefghijklmnopqrstuvwxyz_", c, false))
{
return false
}
pos++
c := SubStr(Name, pos ,1)
}
return true
}
return false
}
RemoveWhiteChars(Text)
{
valid_chars := "01234567890abcdefghijklmnopqrstuvwxyz_"
retstr := ""
pos := 1
c := SubStr(Text, pos ,1)
while(c)
{
if(InStr(valid_chars, c, false))
{
retstr .= c
}
pos++
c := SubStr(Text, pos ,1)
}
return retstr
}
LeadTrim(Text)
{
t := Text
while(SubStr(t, 1 ,1) == " ")
{
t :=SubStr(t, 2)
}
return t
}
WTFAreTheInvalidChars(Text)
{
pos := 1
ln := StrLen(Text)
Debug.MsgBox("LENGTH: " . ln)
loop, %ln%
{
c := SubStr(Text, pos ,1)
a := asc(c)
;if(a<32)
{
;Debug.MsgBox(a)
Debug.Writenl(c . " " . a,100000)
}
pos++
}
}
}