I need a regex expression to detect if a string contains some letters.
The string can contain everything but I need to know if there are some alphabetic characters in.
Public Sub BevatAlphaNumeriek(Str As String) As Boolean
Dim pattern As String = ".*[adehj].*"
Return Regex.IsMatch2(pattern,Regex.CASE_INSENSITIVE,Str)
End Sub
Public Sub BevatAlphaNumeriek(Str As String) As Boolean
Str = Str.Replace(CRLF," ")
Dim pattern As String = ".*[adehj].*"
Return Regex.IsMatch2(pattern,Regex.CASE_INSENSITIVE,Str)
End Sub
Did you try this without having to replace the CRLF with space. It works:
B4X:
Sub BevatAlphaNumeriek(Str As String) As Boolean
Dim pattern As String = ".*[adehj\n].*"
Return Regex.IsMatch2(pattern,Regex.CASE_INSENSITIVE,Str)
End Sub
Your posts did not indicate that before, but I tested it with a string and it worked. That is why you have to explain yourself more clearly to avoid unnecessary posts from others.
I tried my code like this:
Sub BevatAlphaNumeriek(Str As String) As Boolean
' Dim pattern As String = ".*[adehj\n].*"
Dim pattern As String = "(?s).*[adehj].*"
Return Regex.IsMatch2(pattern,Regex.CASE_INSENSITIVE,Str)
End Sub
Hi Oliver: Your pattern produces the same results as the one I posted:
B4X:
Sub BevatAlphaNumeriek(Str As String) As Boolean
' Dim pattern As String = ".*[adehj\n].*"
Dim pattern As String = "(?s).*[adehj].*"
Return Regex.IsMatch2(pattern,Regex.CASE_INSENSITIVE,Str)
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.