CodingI need a regexp

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  af (CAER)  
 To:  ALL
30444.1 
Specifically, a regular expression to use in the Search and Replace box to remove double newlines.

See, I'm on the J-list.com mailing list which is full of interesting things about Japan and stuff, problem is the lines are all double-spaced, like so:
quote:
Well, I'm back in Japan now, the land of sushi and small cars and very cute

things. No matter how often I zip between the U.S. and Japan it always takes a

couple hours to get used to my new environment, and I like to sit back and

"surf" the various shades of culture shock that wash over me (no doubt helped

along by jet lag). As I stepped off the plane this time, I was immediately hit

by the sticky, wet heat that is Japan's June rainy season, an unfortunate

aspect of living here. There was a small mix-up with one of my packages not

appearing on the baggage carousel, which was resolved by three Narita airport

employees who did their jobs so professionally I was actually unable to speak,

so great was my awe while watching them.


I would like to print these e-mails but not with the spacing and stuff like that as it's most unwieldy and just plain wrong :C

PLEASE HELP ME (L)
Caer
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  af (CAER)     
30444.2 In reply to 30444.1 
\n is newline, so replacing \n\n with \n should work.
Unless they also use carriage returns, in which case you'll be wanting something more like \r\n\r\n with \n (or \r\n if necessary)

However, when you say "to use in the Search and Replace box" you have me slightly confused - which search and replace box?
Not all of them do regex.
If you don't already have something that does it, then Metapad (http://liquidninja.com/metapad/) has limited regex, and will work for this (it also avoids the carriage return issue too).
0/0
 Reply   Quote More 

 From:  af (CAER)  
 To:  Peter (BOUGHTONP)     
30444.3 In reply to 30444.2 

Either in OpenOffice Writer or ConTEXT, both of which have a regex option.

 

Now, \n doesn't seem to get found. What's that about then?

Caer
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  af (CAER)     
30444.4 In reply to 30444.3 
Hmmm, maybe try [\n] (although that shouldn't be necessary).

Also worth searching for just \r on the offchance that it's an old Mac file (which wouldn't make sense, but nothing wrong ruling it out).

Oooh, and you may need to turn on multiline mode.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  af (CAER)     
30444.5 In reply to 30444.3 

Are you trying to search for files from within ConTEXT / Writer containing \n or opening the files and searching within them? For whatever reason some editors refuses to find \n in files using the find in files option, but the regular search and replace on opened files will work.

 

Otherwise I must conclude that they're both doing something stupid.

 

And like don't be forgetting that different platforms have different line endings, so while \n\n would work for *nix platforms you'd need to search for \r\n\r\n for Windows and \r\r for Mac.

doohicky

0/0
 Reply   Quote More 

 From:  af (CAER)  
 To:  Matt     
30444.6 In reply to 30444.5 
Well I dunno what was up with ConTEXT but I managed to do it in Writer by first doing a S&R for $^ and replacing it with blank, which removed all empty paragraphs, then I just replaced $ with ' ' which replaced the paragraph breaks with spaces but skipped over the remaining empty paragraphs. All is well.
Caer
0/0
 Reply   Quote More 

Reply to All    
 

1–6

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats