find and replacing

zoboveyes
2013-08-19
2013-08-19
  • zoboveyes

    zoboveyes - 2013-08-19

    hi all,

    Just recently started using notepad++ and find it very powerful and complex , still learning it thou by asking

    well i have a file that has text like this

    John Smith
    123 its a street.
    town, city 11111
    Phone: (555) 555-5555 Email:anyemail@email.com

    John Smith
    123 its a street.
    town, city 11111
    Phone: (555) 555-5555 Email:anyemail@email.com

    John Smith
    123 its a street.
    town, city 11111
    Phone: (555) 555-5555 Email:anyemail@email.com

    is there a way to find and replace in some way to make the text look like below

    \John Smith\ \123 its a street.\ \town, city 11111\

    \John Smith\ \123 its a street.\ \town, city 11111\

    \John Smith\ \123 its a street.\ \town, city 11111\

    is there a way to do this in notepad++ automatically rather than manually.

    thanks in advance

     
  • Loreia2

    Loreia2 - 2013-08-19

    Hi zoboveyes,

    first, tell me what do you want to do with phone and e-mail line? Delete it?

    BR,
    Loreia

     
  • zoboveyes

    zoboveyes - 2013-08-19

    yes, i want the phones and emails deleted

    thanks

     
  • Loreia2

    Loreia2 - 2013-08-19

    Hi,

    1. start replace dialog, CTRL+H
    2. tick regular expression, untick ". matches newline"
    3. get rid of email address line by:
      search: .*@.*
      replace: nothing

    4. convert lines by:
      search: (.+)\r\n
      replace \\\1\\ (there is a space at the end of string!!)

    5. Voilà, you are done :-)

    p.s.
    I followed your sample where every line is separated by double newline. If you wanted to get rid of double newlines:
    search: \r\n\r\n
    replace: \r\n

    BR,
    Loreia

     
    Last edit: Loreia2 2013-08-19
  • zoboveyes

    zoboveyes - 2013-08-19

    that amazing, the conversion of the lines worked perfect but the removal of the emails and phone line only removes the @ sign so i don't know what im doing wrong.

    i followed ur instructions to the letter and could not remove the email but the replacing of the spaces with the \\1\ worked perfect, how do i learn more of such expression when trying to edit file?

    thanks for your assistance, do u have any idea y the removal of the emails is not working?

    i searched for the @ in the find, and i think i actually used both '@' and '.@.' cos i wasn't too sure what u used but none of them worked, also in the replace parts i put nothing and ticked the regular expression and unticked the matchnewline option and still nothing.

    thanks for your time

     
  • zoboveyes

    zoboveyes - 2013-08-19

    I CAN KISS U WHERE EVER U ARE.

    WOW U JUST SAVED ME HOUR

    Thanks a bunch

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks