1. OCAU Merchandise now available! Check out our 20th Anniversary Mugs, Classic Logo Shirts and much more! Discussion here.
    Dismiss Notice

Microsoft word find/replace help

Discussion in 'General Software' started by elementalelf, Oct 21, 2012.

  1. elementalelf

    elementalelf Member

    Joined:
    Feb 11, 2005
    Messages:
    1,467
    Location:
    Newcastle, warnersbay
    I've just OCR'd some documents which now looks like this in MSword:
    I want to use find/replace to look like this:
    so far I've tried:

    Find: >([A-Z]) Replace:^p
    find: ([A-Z]) ([1-9]) Replace: ^11

    And even tried to make an AutoHotkey script to do it(Just started learning the language)

    Nothing has worded so far regardless of the settings I try. Its frustrating me pretty badly.

    Any help would be appreciated.
     
  2. elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    41,384
    Location:
    Brisbane
    Is it just plain, unformatted text?

    I can do it in 5 seconds in BASH/awk/sed/tr or similar command line tools. NFI how to do it in an office package.
     
  3. OP
    OP
    elementalelf

    elementalelf Member

    Joined:
    Feb 11, 2005
    Messages:
    1,467
    Location:
    Newcastle, warnersbay
    Yes. the way you see it there is exactly the same way you see it in the file, I've just changed some of the numerals/letters.

    If you can do it in bash, I have cygwin so it should be easy enough to port. I just have no idea how to use cygwin.
     
  4. elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    41,384
    Location:
    Brisbane
    Code:
    user@machine$ cat textfile.txt
    2763993 ABCDEF,LMNOP 9189661 STUVWX,YZABCD 2188330 JKLMNO,QRSTUVW
    
    user@machine$ cat textfile.txt | sed -s 's/\([0-9]*\)\(\ \)\([A-Z]*\)\(\,\)\([A-Z]*\)\(\ \)/\1\2\3\4\5\6\n/g'
    2763993 ABCDEF,LMNOP 
    9189661 STUVWX,YZABCD 
    2188330 JKLMNO,QRSTUVW
    
    sed string matches on the regex "numbers-space-letters-comma-letters-space" and replaces that whole sequence with the same thing plus a carriage return.
     
  5. NSanity

    NSanity Member

    Joined:
    Mar 11, 2002
    Messages:
    17,964
    Location:
    Canberra
    The answer for this is to include Carriage Return codes in your find string.

    2763993 ABCDEF,LMNOP<alt+0013>9189661 STUVWX,YZABCD<alt+0013>2188330 JKLMNO,QRSTUVW<alt+0013>
     

Share This Page

Advertisement: