View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Tricky regular expression

Hi Robert,

Am Thu, 16 May 2019 02:40:10 -0700 (PDT) schrieb RG III:

Hi Claus. Here's a different problem.

How can I test if a string begins with 1) one or more characters, 2) is followed by one or more whitespace characters, 3) and followed by any character string mixed with anything, including whitespaces?

Here are some example strings that meet the above criteria:

"b908 g"
"what g. no 99"
"a b"

Here are some example strings that do NOT meet the criteria:

"b9000 " ' There are no chars after the whitespaces
"abc" ' Missing whitespaces and chars at the end
"ab" ' Missing whitespaces and chars at the end


try it with this function:

Function StrChk(myRng As Range) As Boolean
Select Case Asc(Left(myRng, 1))
Case 97 To 122
Select Case Asc(Right(myRng, 1))
Case 48 To 122
If InStr(myRng, " ") 0 Then StrChk = True
End Select
End Select
End Function

If your string is in A1 call the function in the sheet with
=StrChk(A1)

If some strings don't work with that function, please poste the not
working examples. Then we must do it with Regular Expression.



Regards
Claus B.
--
Windows10
Office 2016