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