View Single Post
  #2   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,

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))


Regards
Claus B.
--
Windows10
Office 2016