how to move text to other location in notepad
-
Hi guy! I want to ow to move text to other location in notepad++ with replace or macro
ex: i have some text:
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note1 the ones who see things note2 differently </p>
<fn=1>text aaaaaa</fn>
<fn=2>text bbbbbb</fn>I want to replace or macro to:
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=1>text aaaaaa</fn> the ones who see things <fn=2>text bbbbbb</fn> differently </p>
that mean i want move text body in tag fn1 to note1!
some body help me!! -
somebody help me pls
-
Hello, @vuvanvui-vui,
UPDATED
03-07-2018
( search regex changed in order to match a several digits number ! )Not totally sure that it’s what you want to !
Assuming, for instance, the example text, below, where :
-
The first line contains the
note3
andnote4
marks -
The second line contains the
note1
andnote2
marks -
The third line contains the
note5
andnote6
marks -
Somewhere, afterwards, a line beginning with, at least,
3
equal signs ( Note that this sign must NOT be used, anywhere in the current file. You may choose an other symbol, like-
,@
,~
,#
,/
, … ) -
Then, all the
<fn=#...#>text ......</fn>
replacement marks, in a list, with one per line
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note3 the ones who see things note4 differently </p> <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note1 the ones who see things note2 differently </p> <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note5 the ones who see things note6 differently </p> ... ... === Replacement Marks === <fn=1>text aaaaaa</fn> <fn=2>text bbbbbb</fn> <fn=3>text cccccc</fn> <fn=4>text dddddd</fn> <fn=5>text eeeeee</fn> <fn=6>text ffffff</fn>
Then :
-
Open your file in N++ OR just copy / paste all the text, above, in inverse video, in a new tab (
Ctrl + N
) -
Open the Replace dialog (
Ctrl + H
) -
Type in the regex
(?-i)\bnote(\d+)\b(?s)(?=.*\R((?-s)<fn=\1>.*))|^===.+
in the Find what: zone -
Type in the regex
?2\2
, in the Replace with: zone -
Tick the
Wrap around
option and select theRegular expression
search mode -
Click, once, on the Replace All button ( or several times on the Replace button ! )
Et voilà ! You should get the following text :
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=3>text cccccc</fn> the ones who see things <fn=4>text dddddd</fn> differently </p> <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=1>text aaaaaa</fn> the ones who see things <fn=2>text bbbbbb</fn> differently </p> <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=5>text eeeeee</fn> the ones who see things <fn=6>text ffffff</fn> differently </p>
Best Regards,
guy038
P.S. :
Next time, if you would like to, I’ll explain how this regex S/R works :-))
-
-
@guy038 thanks you verymuch sir!, ;)
P/S: Next time, if you would like to, I’ll explain how this regex S/R works :-)) (i’m understand)
-
hi @guy038 if i want to:
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note3 the ones who see things note4 differently </p>
<fn=3>text cccccc</fn>
<fn=4>text dddddd</fn>
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note1 the ones who see things note2 differently </p>
<fn=1>text aaaaaa</fn>
<fn=2>text bbbbbb</fn>
<p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note5 the ones who see things note6 differently </p>
<fn=5>text eeeeee</fn>
<fn=6>text ffffff</fn>can you help me?
-
Hi, @vuvanvui-vui,
I’m sorry, but it’s not very clear what you would like to :
-
Are the lines
<p>Here’s to........differently </p>
consecutive or embedded among other lines ? -
Are the lines
<fn=#>text aaaaaa</fn>
located anywhere, in your file or mixed with the<p>Here’s to........differently </p>
ones ?
In other words, could you show us :
-
The text ( or part of it ), what you get, presently, before process
-
The text that you expect to, after process
It’s always better to work with true material !
Note that, may be, it won’t be possible to get it with regular expressions, but, ONLY, with a scripting language, as the Lua or Python plugin !
If your file contents are not confidential, you could, also, send me an e-mail, with your file attached, at :
Cheers,
guy038
-
-
thanks @guy038 , I started to really enjoy python, thankyou verymuch :)