How to separate values
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 8
- Joined: Mon Feb 13, 2012 7:55 pm
How to separate values
R74862 60009AG10C9P 0050
I have to separate the above values based on space?? any suggestion pls
I have to separate the above values based on space?? any suggestion pls
hagchr,
Highlight the code then click the "Code" button (Just below the "Subject" line)
I also have:
Disable HTML in this post
Disable Smilies in this post
Attach signature (signatures can be changed in profile)
Notify me when a reply is posted
all checked
Highlight the code then click the "Code" button (Just below the "Subject" line)
I also have:
Disable HTML in this post
Disable Smilies in this post
Attach signature (signatures can be changed in profile)
Notify me when a reply is posted
all checked
Code: Select all
Let>tmp=R74862 60009AG10C9P 0050
Separate>tmp, ,arrItems
Let>ct=0
While>ct<arrItems_count
Let>ct=ct+1
MessageModal>arrItems_%ct%
EndWhile
-
- Newbie
- Posts: 8
- Joined: Mon Feb 13, 2012 7:55 pm
An alternative (for example if you have variable number of spaces between strings) would be to use RegEx
Code: Select all
Let>tmp=R74862 60009AG10C9P 0050
RegEx>[^\s]+,tmp,0,Matches,NumMatches,0,,
Let>ct=0
While>ct<NumMatches
Let>ct=ct+1
Messagemodal>Matches_%ct%
EndWhile
Hi hagchr,
Nice regex solution... it could also be written like this:
See http://www.regular-expressions.info/shorthand.html and section on Negated Shorthand Character Classes.
Also in the RegEx> command, if the Replace Flag is 0 then the next two commas are not required at the end... but don't hurt.
Thanks again for this solution... very useful!
Nice regex solution... it could also be written like this:
Code: Select all
Let>tmp=R74862 60009AG10C9P 0050
RegEx>[\S]+,tmp,0,Matches,NumMatches,0
Let>ct=0
While>ct<NumMatches
Let>ct=ct+1
Messagemodal>Matches_%ct%
EndWhile
Actually you could dispense with the character class (the [] brackets) completely and just write it as shown below...info at the link above wrote:\s stands for "whitespace character"... that is: \s matches a space, a tab, a line break, or a form feed.
\S is the negated form of the above... and equivalent to [^\s] inside that character class.
Code: Select all
Let>tmp=R74862 60009AG10C9P 0050
RegEx>\S+,tmp,0,Matches,NumMatches,0
Let>ct=0
While>ct<NumMatches
Let>ct=ct+1
Messagemodal>Matches_%ct%
EndWhile
Thanks again for this solution... very useful!
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
