The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-22-2005
Simerian Simerian is offline
Registered User
 

Join Date: Oct 2003
Location: United Kingdom
Posts: 37
GnuWin32 sed 4.1.4 regexp matching

I am using GnuWin32 sed and am having trouble with the regexp - i.e., they don't behave the same way as in UNIX (POSIX and and all that). I have a stream of data, e.g.:

11111'222?'22'33?'333'44444'55555'

I want to insert a \n after those apostrophes that are *not* preceded by a ?.

Expected output:

11111'
222?'22'
33?'333'
44444'
55555'

I used the substitution:

s/\([^?]\)'/\1'\n/g

this should be OK but it didn't work... it replaced those that *did* have a ? in front - I want the opposite.

Any gurus with a suggestion? (apart from sticking to UNIX)
Reply With Quote
Forum Sponsor