Sub CheckValidEmail (Email)
'The pattern was copied from this site: www.regular-
expressions.info
Regex1.New2("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$",True,False) 'We are using case insensitive regex.
If Regex1.IsMatch(Email) Then
Msgbox(Email & " is a valid address")
Else
Msgbox(Email & " is not a valid
address","",cMsgboxOK,cMsgboxHand)
End If
End Sub
Sub TrimTrailingAndLeadingSpaces
Regex1.New1("(?<=^\s*)\w.*\w|\w(?>=\s*)") 'We are using look
behind and look ahead in this pattern.
Match1.Value = Regex1.Match(" Some string with spaces ")
Msgbox(Match1.String)
End Sub
Sub CapitalizeFirstLetterInSentence
Regex1.New1("(?<=\.\s*|^)(\w)(\w*)") 'We are using two groups in
this pattern.
s = "this is a long string. the brown fox jumped over the fence.
regex are much simpler than they first seem."
Match1.Value = Regex1.Match(s)
Do While Match1.Success
s = StrRemove(s,Match1.Index,Match1.Length)
s = StrInsert(s,Match1.Index,StrToUpper(Match1.GetGroup(1))
& Match1.GetGroup(2))
Match1.Value = Match1.NextMatch 'Step to the next match.
Loop
Msgbox(s)
End Sub