Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Deleting a specific sequence of characters (linebreaks?) from astring

Reply
Thread Tools

Deleting a specific sequence of characters (linebreaks?) from astring

 
 
Aldric Giacomoni
Guest
Posts: n/a
 
      02-18-2009
I need to delete a sequence of characters like '\\n' from a string - but I don't want to delete every 'n' and every '\' from it! So .. "delete" doesn't seem to be an option and I can't get "gsub" to do what I want. Is there a tried and true solution that I just haven't found? Here is an example test, straight from the document itself:

Soft linebreaks are linebreaks preceeded by '\\' like this one >o\
k<. Hard line breaks are all other linebreaks.
Soft linebreaks are converted to >nothing<, i.e. removed.

Note that linebreaks are coded differently on different systems.

Examples (>ok< shouldn't be split):

linebreak 1 "\\n": >o\
k<
linebreak 2 "\\n\\r": >o\

k<
linebreak 3 "\\r\\n": >o\
k<
linebreak 4 "\\r": >o\
k<]


Expected result is that >ok< looks normal on all lines - I don't know how to make that happen. Can anyone enlighten me .. Or put me on the path?

Thanks,
--Aldric
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call function whose function call with arguments is in astring grbgooglefan C++ 2 01-30-2008 07:18 AM
Is there a string function to trim all non-ascii characters out of astring silverburgh.meryl@gmail.com Python 10 12-31-2007 01:51 PM
Question about astring.getBytes() and a byteArray.toString() Andrew Java 5 09-28-2004 03:59 PM
Deleting specific characters from a string Behrang Dadsetan Python 17 07-11-2003 02:49 PM
RE: Deleting specific characters from a string Michael Chermside Python 1 07-10-2003 03:29 PM



Advertisments