I have a line of text from the clipboard that contains four numbers separated by a variable number of spaces. I need to parse these numbers into four variables.
I tried using the separate command, but no luck. I either get one variable with the entire string or a variable for each character.
Thanks
Remove multiple spaces from text
Moderators: JRL, Dorian (MJT support)
Regular Expressions will do this. "\s+" means any number of space characters. So the following function replaces whitespace with any single character of your choice. In the example below I replace whitespace with one single space character. E.g. any number of spaces together are replaced with one space character:
VBSTART
Function ReplWhiteSpace(strng,replchar)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "\s+"
regEx.Global = True
ReplWhiteSpace = regEx.Replace(strng,replchar)
End Function
VBEND
Let>Line=Hello How Are you today?
VBEval>ReplWhiteSpace("%Line%"," "),newval
Once you've done this it will be easy to use Separate to extract each part separated by the space (or whatever delimiter you choose to pass in as the second parameter of ReplWhiteSpace).
VBSTART
Function ReplWhiteSpace(strng,replchar)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "\s+"
regEx.Global = True
ReplWhiteSpace = regEx.Replace(strng,replchar)
End Function
VBEND
Let>Line=Hello How Are you today?
VBEval>ReplWhiteSpace("%Line%"," "),newval
Once you've done this it will be easy to use Separate to extract each part separated by the space (or whatever delimiter you choose to pass in as the second parameter of ReplWhiteSpace).
MJT Net Support
[email protected]
[email protected]