lpatnaik
Programmer
- Jul 11, 2002
- 53
Hi,
How can I implement the regular expressions in VB in a way so that the result set gives me all the invalid characters in a word.
To explain:
I have a word "ABC%DEF~GHI^JKL#MNO"
I want to find out what all invalid characters are there in the word, given that "%", "~" and "#" are invalid.
The following code, only returns the first inalid character in list.
Dim reg As New RegExp
Dim strTest As String
Dim regPattern As String
Dim Matches As MatchCollection
Dim mtch As Match
Dim blnFound As Boolean
strTest = "ashasd^$%@$~@#@Q%~$#"
regPattern = "\[%^<>#\]?\[]"
With reg
.Pattern = regPattern
If .Test(strTest) = True Then
Set Matches = .Execute(strTest)
For Each mtch In Matches
MsgBox mtch.Value
Next mtch
ValidateManuOrdID = True
End If
End With
Set reg = Nothing
Please reply ASAP
How can I implement the regular expressions in VB in a way so that the result set gives me all the invalid characters in a word.
To explain:
I have a word "ABC%DEF~GHI^JKL#MNO"
I want to find out what all invalid characters are there in the word, given that "%", "~" and "#" are invalid.
The following code, only returns the first inalid character in list.
Dim reg As New RegExp
Dim strTest As String
Dim regPattern As String
Dim Matches As MatchCollection
Dim mtch As Match
Dim blnFound As Boolean
strTest = "ashasd^$%@$~@#@Q%~$#"
regPattern = "\[%^<>#\]?\[]"
With reg
.Pattern = regPattern
If .Test(strTest) = True Then
Set Matches = .Execute(strTest)
For Each mtch In Matches
MsgBox mtch.Value
Next mtch
ValidateManuOrdID = True
End If
End With
Set reg = Nothing
Please reply ASAP