1

I have just started playing around with text editing using Text Wrangler. I have real estate sales data cut and pasted from a web site on which I have searched and deleted unwanted data and cleaned up the tabs and spaces nicely. However each data record is still split over 2 lines. One line starts with a letter (persons name) and the next starts with an address (a digit). This pattern repeats all the way down the document. How do I say "if line break is followed on next line with a starting digit, replace line break with a tab"

I assume that would put each record on one line ?

3
  • Have you tried regular expression matching, combined with the \n line break character?
    – user479
    Commented Sep 20, 2011 at 5:52
  • I guess thats what I'm asking, what is the correct grep pattern. I was using \r (mac) as opposed \n (unix) but neither work. What I think should work is find: \r +[D] replace:\t note i got the example back to front above the first line starts with a digit the 2nd with a letter.
    – Visitor82
    Commented Sep 20, 2011 at 6:04
  • I'm out of my depth with regex, sorry. That's why I didn't post a proper answer! Retag your question with regex and maybe you'll get more love.
    – user479
    Commented Sep 20, 2011 at 6:05

1 Answer 1

1

I'm assuming you want it like:

Visitor82   123 E. Text Street ...

To do this in Text Wrangler:

  1. Search > Find

  2. Tick the 'Grep' option

  3. In the Find Box type:

    (?(?!\r\d)then)\r

  4. In the Replace Box type (or whatever delimiter you would like):

    \x20

~ Enjoy!

Text Grepping!

2
  • Brilliant ! I had to use D rather than d to represent any non digit character but that worked. Now I will try and work out why ;-) Thanks @ioi
    – Visitor82
    Commented Sep 20, 2011 at 8:29
  • Interesting, \d denotes [digit] and \D [not a digit], so that's got me scratching my head! I'm glad it worked for you; I love Regex, it's language theory and mathematics all rolled into one. ;-)
    – l'L'l
    Commented Sep 20, 2011 at 10:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .