[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: patten match

Bira

6/29/2007 8:46:00 PM

On 6/19/07, geetha <sangeetha.geethu05@gmail.com> wrote:
> Hi Good morning,
>
> I am having one text file. In this I need to remove all the new lines
> and I need to match the keyword what I am giving.
>
> Please any one help me....
>
> Thanks,
> S.Sangeetha.

For removing newlines, you can use the String#gsub method, like this:

"one line\nother line".gsub("\n",'')

don't forget to use double quotes on the "\n" - they tell Ruby to
interpret the "slash-letter" combos as special characters, rather than
as a slash followed by a letter. "\n" is a newline.

For matching a word, you can use regular expressions - they're a
fairly interesting, but somewhat complicated topic, and you would be
much better served by looking for a Ruby regular expression tutorial
in Google.

--
Bira
http://compexplicita.bl...
http://sinfoniaferida.bl...