Difference between revisions of "Microsoft Access modString"
Jump to navigation
Jump to search
(Created page with '=== getAlNumString === <syntaxhighlight lang="vb"> Public Function getAlNumString(strSource As String) As String Dim strResult As String Dim intIndex As Integer Dim...') |
|||
Line 94: | Line 94: | ||
=== matches === | === matches === | ||
<syntaxhighlight lang="vb"> | <syntaxhighlight lang="vb"> | ||
− | Public Function matches(strString As String, strRegEx As String) As Boolean | + | Public Function matches(strString As String, strRegEx As String, Optional blnIgnoreCase As Boolean = False) As Boolean |
Dim blnResult As Boolean | Dim blnResult As Boolean | ||
− | + | ||
Dim rgx As RegExp | Dim rgx As RegExp | ||
− | + | ||
Set rgx = New RegExp | Set rgx = New RegExp | ||
With rgx | With rgx | ||
+ | .IgnoreCase = blnIgnoreCase | ||
.Pattern = strRegEx | .Pattern = strRegEx | ||
blnResult = .Test(strString) | blnResult = .Test(strString) | ||
End With | End With | ||
− | + | ||
matches = blnResult | matches = blnResult | ||
End Function | End Function | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 23:31, 13 July 2010
getAlNumString
Public Function getAlNumString(strSource As String) As String
Dim strResult As String
Dim intIndex As Integer
Dim strCharacter As String
strResult = ""
For intIndex = 1 To Len(strSource)
strCharacter = Mid(strSource, intIndex, 1)
Select Case Asc(strCharacter)
''A - Z, a - z
Case 65 To 90, 97 To 122
strResult = strResult & strCharacter
'0 - 9
Case 48 To 57
strResult = strResult & strCharacter
Case Else
'nothing
End Select
Next
getAlNumString = strResult
End Function
getAlNumPunctString
Public Function getAlNumPunctString(strSource As String) As String
Dim strResult As String
Dim intIndex As Integer
Dim strCharacter As String
strResult = ""
For intIndex = 1 To Len(strSource)
strCharacter = Mid(strSource, intIndex, 1)
Select Case Asc(strCharacter)
'A - Z, a - z
Case 65 To 90, 97 To 122
strResult = strResult & strCharacter
'0 - 9
Case 48 To 57
strResult = strResult & strCharacter
'<space>, <comma>, <hyphen>, <dot>, <slash>
Case 20, 44 To 47
strResult = strResult & strCharacter
Case Else
'nothing
End Select
Next
getAlNumPunctString = strResult
End Function
getPrintableString
Public Function getPrintableString(strSource As String) As String
Dim strResult As String
Dim intIndex As Integer
Dim strCharacter As String
strResult = ""
For intIndex = 1 To Len(strSource)
strCharacter = Mid(strSource, intIndex, 1)
Select Case Asc(strCharacter)
'ASCII printable characters
Case 20 To 126
strResult = strResult & strCharacter
Case Else
'nothing
End Select
Next
getPrintableString = strResult
End Function
matches
Public Function matches(strString As String, strRegEx As String, Optional blnIgnoreCase As Boolean = False) As Boolean
Dim blnResult As Boolean
Dim rgx As RegExp
Set rgx = New RegExp
With rgx
.IgnoreCase = blnIgnoreCase
.Pattern = strRegEx
blnResult = .Test(strString)
End With
matches = blnResult
End Function