View Single Post
  #2   Report Post  
Old May 14th 19, 11:12 AM posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
First recorded activity by ExcelBanter: Apr 2011
Posts: 3,673
Default Tricky regular expression


Am Tue, 14 May 2019 02:57:53 -0700 (PDT) schrieb RG III:

sLine = "abc G. James #000"

I'm only interested in extracting TWO fragments as follows:
The first extracted fragment should be "abc"
The second extracted fragment should be "G. James #000"

Is there a regular expression pattern that might be able to extract the above fragments?

In general, I'm trying to divide any input string into 2 pieces, and the dividing point is the first set of whitespaces that occur in the line. In the above example, the dividing point occurs right after the "abc".

try it this way:

sLine = "abc G. James #000"
sLine = Application.Substitute(sLine, " ", "*", 1)
varTmp = Split(sLine, "*")
str1 = varTmp(0)
str2 = Trim(varTmp(1))

Claus B.
Office 2016