[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Regexp.newbie?

dave rose

1/19/2007 9:20:00 PM

i've got a whole file to scan...but can't get neatly get the last
occurance with...
.scan(/(^A.*?)^A/m){|a| stops<<$1} ...yes i know that last occurance
is not scanned
because it is succeeded with ^Z line....that's the complication....
A......
M.....
d....
A....
r....
f....
A....
.... etc to the last A group....
A.....
c....
t....
Z.....

note each ^A group can end only with a new occurance of another A
record or the Z record.which
is the last record of the file....So? how do make a more eligant Reg
expression to cover this
situation?

--
Posted via http://www.ruby-....

6 Answers

WoNáDo

1/19/2007 9:48:00 PM

0

Hope there is one solution O.K. for you.

>>>>> Code >>>>>

mylines = <<EOT
A......1
M.....
d....
A....1
r....
f....
A.....1
c....
t....
Z.....
EOT
puts '########## Without last Z-Record ##########'
mylines.scan(/^A.*?(?=^(?:A|Z))/m){|a|puts "#{a}\n----------"}
puts '########## Last Record up to EOF ##########'
mylines.scan(/^A.*?(?=^A|\Z)/m){|a|puts "#{a}\n----------"}
puts '########## Includings last Z-Record ##########'
mylines.scan(/^A.*?(?:(?=^A)|^Z.*$)/m){|a|puts "#{a}\n----------"}

>>>>> Results >>>>>

########## Without last Z-Record ##########
A......1
M.....
d....

----------
A....1
r....
f....

----------
A.....1
c....
t....

----------
########## Last Record up to EOF ##########
A......1
M.....
d....

----------
A....1
r....
f....

----------
A.....1
c....
t....
Z.....
----------
########## Includings last Z-Record ##########
A......1
M.....
d....

----------
A....1
r....
f....

----------
A.....1
c....
t....
Z.....

----------

>>>>> End >>>>>

Wolfgang Nádasi-Donner

dave rose

1/22/2007 1:50:00 PM

0

Wolfgang Nádasi-donner wrote:
> Hope there is one solution O.K. for you.
>
> >>>>> Code >>>>>
>
> mylines = <<EOT
> A......1
> M.....
> d....
> A....1
> r....
> f....
> A.....1
> c....
> t....
> Z.....
> EOT
> puts '########## Without last Z-Record ##########'
> mylines.scan(/^A.*?(?=^(?:A|Z))/m){|a|puts "#{a}\n----------"}
> puts '########## Last Record up to EOF ##########'
> mylines.scan(/^A.*?(?=^A|\Z)/m){|a|puts "#{a}\n----------"}
> puts '########## Includings last Z-Record ##########'
> mylines.scan(/^A.*?(?:(?=^A)|^Z.*$)/m){|a|puts "#{a}\n----------"}



...wow...thanx..a whole lot..dave

--
Posted via http://www.ruby-....

NoSpamAtAll

12/6/2012 5:24:00 PM

0

In article <50c0d2b3$0$47720$2e0edba0@news.tweakdsl.nl>,
Heinrich <Heinrich@Ruhrgasnet.de> wrote:

> your presence on this globe is no asset to humanity

Your wife and daughter differ on that, dutch pig! :)

Heinrich

12/6/2012 5:31:00 PM

0



"NoSpamAtAll" schreef in bericht news:k9qkbk$g9e$1@pcls6.std.com...

In article <50c0d2b3$0$47720$2e0edba0@news.tweakdsl.nl>,
Heinrich <Heinrich@Ruhrgasnet.de> wrote:

> your presence on this globe is no asset to humanity

Your wife and daughter differ on that, dutch pig! :)

just do as told and stop babbling

The Peeler

12/6/2012 5:54:00 PM

0

On Thu, 6 Dec 2012 18:15:20 +0100, Dumb Heini, the heavily medicated Dutch
resident Nazi troll and laughing stock of sci and scj, wrote:

> Why do you suck rectums?
>
> your presence on this globe is no asset to humanity so kill yourself

Believe me, Dumb Heini, that's exactly what your wife keeps secretly
thinking about YOU all the time! ;-)


--
Dumb Heini about himself: "i was diagnozed with the syndromeof asperger, no
idea what it means but i am feelingperfectly oke"
MID: <7u8b41FjtnU1@mid.individual.net>

The Peeler

12/6/2012 5:56:00 PM

0

On Thu, 6 Dec 2012 18:31:04 +0100, Dumb Heini, the heavily medicated Dutch
resident Nazi troll and laughing stock of sci and scj, wrote:


>> your presence on this globe is no asset to humanity
>
> Your wife and daughter differ on that, dutch pig! :)
>
> just do as told and stop babbling

Just do as everyone around you keeps telling you and phone them up here:

Stichting Levenseindekliniek,
Tel: 070 352 4141 (09:30 ?V 16:30 uur)


--
Dumb Dutch Nazi Heini about his personal misery: "I FEEL LONELY AT THE
MOMENT, IT IS RAining again and the sky is grey so a perfect scenbario to
commit suicide"
Message-ID: <vegVo.11791$jj5.10722@newsfe03.iad>