|
|
| Author |
Message |
rohitsir
New User
Joined: 21 Aug 2007 Posts: 32 Location: USA
|
|
|
|
I have a string:
DEFINE SBR NAME='SC#HOG',
I want to parse the string data such that I get SC#HOG in a separate field without quotes. Can I do this just using single PARSE VAR instruction ??? |
|
| Back to top |
|
 |
References
|
Posted: Fri Mar 14, 2008 4:00 am Post subject: Re: Single quote delimiter in parsing |
 |
|
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 3094 Location: Charlotte,NC USA
|
|
|
|
Does this work for you?
string = "DEFINE SBR NAME='SC#HOG',"
...
Parse Var string . "'" varname "'" .
or
Parse Var string . '=' varname ',' .
varname = Strip(varname,B,"'") |
|
| Back to top |
|
 |
rohitsir
New User
Joined: 21 Aug 2007 Posts: 32 Location: USA
|
|
|
|
The first approach doesn't work. I have already tried it. The second approach does work. I have done sth different to achieve it.
LEN = LENGTH(VARNAME)
VARNAME = LEFT(VARNAME,LEN - 1)
VARNAME = RIGHT(VARNAME,LEN - 2)
Thanks for the reply. |
|
| Back to top |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 3094 Location: Charlotte,NC USA
|
|
|
|
| rohitsir wrote: |
| The first approach doesn't work. |
Yes it does.
| Code: |
3 *-* string = "DEFINE SBR NAME='SC#HOG',"
>L> "DEFINE SBR NAME='SC#HOG',"
4 *-* Parse Var string . "'" varname "'" .
>.> "DEFINE SBR NAME="
>>> "SC#HOG"
>.> ","
5 *-* Say varname
>V> "SC#HOG"
SC#HOG
6 *-* Exit 0
>L> "0"
|
|
|
| Back to top |
|
 |
rohitsir
New User
Joined: 21 Aug 2007 Posts: 32 Location: USA
|
|
|
|
| My bad. It does work. |
|
| Back to top |
|
 |
|
|