Help on {FS= string1|string2} ? 
Author Message
 Help on {FS= string1|string2} ?

Hello,
This is a silly question on how to set up multiple FS values,
I need to parse lines that look aprox. like this (all one line),
<H2>blahblah # 34 blah on 18/03/97 blah DonorBelgiumValue918.196
ECURecipientRWANDABlah
In order to have a file with lines like this:
Belgium,918196,RWANDA etc

I guess I should set up FS = string1 OR string2 OR string3, using a
REGEXP.
I have tried in the BEGIN line things like
{FS=/Donor/|/Value/}
{FS="/Donor/|/Value/"}
{FS="[/Donor|Value/]"}
But no success so far. {I use gawk 3.0.4 for DOS (djgpp)).
Thanks in advance.



Sat, 10 Jan 2004 01:58:16 GMT  
 Help on {FS= string1|string2} ?

Quote:

> This is a silly question on how to set up multiple FS values,
> I need to parse lines that look aprox. like this (all one line),
> <H2>blahblah # 34 blah on 18/03/97 blah DonorBelgiumValue918.196
> ECURecipientRWANDABlah
> In order to have a file with lines like this:
> Belgium,918196,RWANDA etc

> I guess I should set up FS = string1 OR string2 OR string3, using a
> REGEXP.
> I have tried in the BEGIN line things like
> {FS=/Donor/|/Value/}
> {FS="/Donor/|/Value/"}
> {FS="[/Donor|Value/]"}
> But no success so far. {I use gawk 3.0.4 for DOS (djgpp)).

You were close. Try this:

    BEGIN { FS = "Donor|Value|Recipient|Blah" }

Are you sure that's going to be The Best Way to parse those (weird)
lines?

--
Jim Monty

Tempe, Arizona USA



Sat, 10 Jan 2004 04:22:55 GMT  
 Help on {FS= string1|string2} ?

Quote:

> Hello,
> This is a silly question on how to set up multiple FS values,
> I need to parse lines that look aprox. like this (all one line),
> <H2>blahblah # 34 blah on 18/03/97 blah DonorBelgiumValue918.196
> ECURecipientRWANDABlah
> In order to have a file with lines like this:
> Belgium,918196,RWANDA etc

> I guess I should set up FS = string1 OR string2 OR string3, using a
> REGEXP.
> I have tried in the BEGIN line things like
> {FS=/Donor/|/Value/}
> {FS="/Donor/|/Value/"}
> {FS="[/Donor|Value/]"}
> But no success so far. {I use gawk 3.0.4 for DOS (djgpp)).
> Thanks in advance.

FS="(Donor)|(Value)"

vlad



Sat, 10 Jan 2004 07:09:57 GMT  
 Help on {FS= string1|string2} ?
Thank you very much,
Vlad's solution worked.

Quote:

> > This is a silly question on how to set up multiple FS values,
> > I need to parse lines that look aprox. like this (all one line),
> > <H2>blahblah # 34 blah on 18/03/97 blah DonorBelgiumValue918.196
> > ECURecipientRWANDABlah
> > In order to have a file with lines like this:
> > Belgium,918196,RWANDA etc

<snip>

> FS="(Donor)|(Value)"

> vlad



Tue, 13 Jan 2004 02:43:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. help centering string1 into string2

2. What does #ORIG(?String1) mean?

3. FS: Mr. Debug, Multi-Edit Pro, Grok, Broplus, Expert Help, Star Class, R&R

4. Smalltalk Books FS

5. FS FastCGI and IIS

6. Everything you EVER DID is STILL STORED IN YOUR PC ( g029 fs)

7. FS: APL Conference proceedings of possible historical interest

8. FS: IBM System/370 Emergency Pull Knob

9. FS: IBM System/360 Reference Card

10. FS: ALGEBRA -- An Algorithmic Treatment book

11. FS:text - assembler 370

 

 
Powered by phpBB® Forum Software