Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: scanning strings, backward?
Cameron, Gemma (UK)
10/11/2006 1:00:00 PM
I think Bil just wants to remove part of the line rather than all of it:
> 3) Remove /dt/i
i.e.
line.gsub!(/\/dt\/i/, '')
Using String::gsub as suggested by Vidar
Gem
-----Original Message-----
From: M. Edward (Ed) Borasky [mailto:znmeb@cesmail.net]
Sent: 11 October 2006 13:50
To: ruby-talk ML
Subject: Re: scanning strings, backward?
*** WARNING ***
This mail has originated outside your organization, either from an
external partner or the Global Internet.
Keep this in mind if you answer this message.
Bil Kleb wrote:
> Hi,
>
> I would like to automate a code cleanup task which involves finding
> warning messages like,
>
> Warning: ../../LibF90/bc_inviscid.f90, line 1707:
> DT explicitly imported into BC_INVISCID_FLUX but not used detected
> at BC_INVISCID_FLUX@<end-of-statement>
>
> and removing the offending unused import.
>
> So, the tasks are roughly,
>
> 1) Goto line 1707 of the file
> 2) Search backward until line.match /\Wdt\W/i
> 3) Remove /dt/i
>
> I'm stuck on an elegant, i.e., Ruby, way to do the first two steps.
> Please point me toward the glittering light.
>
> Thanks,
> --
> Bil Kleb
>
http://fun3d.lar...
Wait a minute ... is the file you're editing always a Fortran source?
Why not just comment out the offending line rather than removing it?
Otherwise, removing a line changes the position number of every line
following it.
>
>
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
1 Answer
Bil Kleb
10/11/2006 1:37:00 PM
0
Cameron, Gemma (UK) wrote:
> I think Bil just wants to remove part of the line rather than all of it:
>
> > 3) Remove /dt/i
>
> i.e.
> line.gsub!(/\/dt\/i/, '')
Yes
And sorry for the confusing example; I should have written, %r{/dt/i}.
Regards,
--
Bil Kleb
http://fun3d.lar...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: scanning strings, backward?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password