Replacing a column of numbers with clipboard data
-
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! -
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 (
6rows x2columns ), 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.75If 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 valOPTIONS
Wrap aroundandRegular expressionsetAnd 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login