Community
    • Login

    Replacing a column of numbers with clipboard data

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • xerkonX
      xerkon
      last edited by

      Hi. I have a 2 columns of values that I’d like to replace. Let me show an example:

      <controlpoint t=“0.46” val=“1.0”/>
      <controlpoint t=“8.21” val=“0.9”/>
      <controlpoint t=“12.32” val=“1.02”/>
      <controlpoint t=“20.94” val=“0.95”/>
      <controlpoint t=“29.27” val=“1.09”/>
      <controlpoint t=“40.01” val=“0.958”/>

      I’m needing to replace everything that is italicized. (If I have to do it a column at a time, that’s okay.) I’d like to be able to copy 2 columns from a spreadsheet and replace all values. So if I have a column with:
      1.25
      2.5
      3.25
      4.5
      5.25
      6.5
      and a second column:
      0.25
      0.5
      1.25
      1.5
      2.25
      2.75
      is there a way to copy to clipboard and then paste into Notepad++ with the result being:
      <controlpoint t=“1.25” val=“0.25”/>
      <controlpoint t=“2.5” val=“0.5”/>
      <controlpoint t=“3.25” val=“1.25”/>
      <controlpoint t=“4.5” val=“1.5”/>
      <controlpoint t=“5.25” val=“2.25”/>
      <controlpoint t=“6.5” val=“2.75”/>
      ?
      Thanks!

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by

        Hello, @xerkon,

        As you said :

        I’d like to be able to copy 2 columns from a spreadsheet

        I suppose that your selected bloc of cells ( 6 rows x 2 columns ), pasted in a new tab, within N++, is displayed, as below, where any number of the second column is simply separated, from its associated number of the first column, by a tabulation character ( \t ) !

        1.25	0.25
        2.5	0.5
        3.25	1.25
        4.5	1.5
        5.25	2.25
        6.5	2.75
        

        If so, the simple regex S/R should do the job :

        SEARCH (?-s)^(.+?)\t(.+)

        REPLACE <controlpoint t="\1" val="\2"/> , with a space character, before the string val

        OPTIONS Wrap around and Regular expression set

        And you’ll get the text :

        <controlpoint t="1.25" val="0.25"/>
        <controlpoint t="2.5" val="0.5"/>
        <controlpoint t="3.25" val="1.25"/>
        <controlpoint t="4.5" val="1.5"/>
        <controlpoint t="5.25" val="2.25"/>
        <controlpoint t="6.5" val="2.75"/>
        

        If you prefer separate the two values by a tabulation character, just change the Replace box, as belwo :

        REPLACE <controlpoint t="\1"\tval="\2"/>

        This time, you would obtain :

        <controlpoint t="1.25"	val="0.25"/>
        <controlpoint t="2.5"	val="0.5"/>
        <controlpoint t="3.25"	val="1.25"/>
        <controlpoint t="4.5"	val="1.5"/>
        <controlpoint t="5.25"	val="2.25"/>
        <controlpoint t="6.5"	val="2.75"/>
        

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors