• Delete line with duplicate Number

    6
    0 Votes
    6 Posts
    683 Views
    guy038G

    Hello @jim-erlich and All,

    Sorry for being late ! So, here are, below, some explanations about my regex S/R :

    SEARCH (?-s)^.+#\x20?(\d+)\R(?=.+#\x20?\1)

    REPLACE Leave EMPTY

    First, the (?-s) in-line modifier ensures that any further . regex symbol corresponds to a single standard character, only and not to a line-break char !

    So, the next part ^.+#\x20? searches, from beginning of line ( ^ ), any non-null range of characters ( .+ ), followed by the # symbol and an optional space char (\x20?)

    Then, it looks for a non-null range of digits ( \d+ ), followed by line-break character(s)

    So, the regex engine looks for an entire line ( digits after the # are stored as group 1 as embedded in parentheses ) but ONLY IF the next line ends with the same number !

    This condition can be expressed with a look-ahead structure (?=......) which are rather a user assertion in the same way that, for instance, the $ symbol is a system assertion, looking for the zero length assertion “end of line” !

    So current line must be followed with the regex .+#\x20?\1, which represents, again, a non-null range of standard characters followed with a # and possibly a space char and finally the group 1 ( \1 ) which is the ending number of the current line

    Note that the ^ assertion for the second line, in the look-ahead structure, is useless as the range (.+) comes next the line-break char(s) \R, anyway !

    As the replacement zone is empty, the current line, with its line-break, is just deleted

    For a quick oversight about regular expressions, see the N++ documentation, below :

    https://npp-user-manual.org/docs/searching/#regular-expressions

    See also the main links regarding the Boost regex library, used by the regex N++ engine :

    https://www.boost.org/doc/libs/1_70_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

    https://www.boost.org/doc/libs/1_70_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

    Finally, see this FAQ topic about regular expressions :

    https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation

    Best Regards,

    guy038

  • From Notepad++ to SSH, wrong conversion

    3
    0 Votes
    3 Posts
    570 Views
    Michael VincentM

    @Dark-Corner

    My guess is line endings. I’m not at computer to show screenshots, but try your cut and paste from N++ with Windows line endings (CR LF) and then try converting your file in N++ to Unix line endings (LF) and try your cut and paste again. I’m betting one will give you the results you want and the other will give you what you’re experience now (undesired).

    Cheers.

  • Substituting exact letter

    11
    0 Votes
    11 Posts
    1k Views
    guy038G

    Hello, @marcos-liell,

    Oh, my God, I had to remember all this old discussion !

    You said :

    when replacing the chord it changes places because of the <b> tag they go forward, would there be a way to move 3 spaces to the left when replacing?

    It’s not very clear to me ! So, would you mind showing :

    An example of your initial text

    Which search and replacement regexes did you use

    The resulting text that you obtained

    And the text that you would expect to !

    Thanks !

    Best Regards,

    guy038

  • How to find/replace a character in every specific line

    3
    0 Votes
    3 Posts
    4k Views
    guy038G

    Hello, @johnny27 and All,

    Interesting problem ! And easy to solve with, both, regular expressions and the Column Editor ;-))

    Here is the road map :

    Open your file in Notepad++

    Place th caret at the very beginning of the first line

    Open the Column Editor ( Alt + C )

    Select Number to Insert

    Type in 1 in all zones

    Tick the Leading zeros option ( IMPORTANT )

    Select the Dec format, if necessary

    Click on the OK button

    => Each line should be preceded with a 6 digits number !

    Now, open the Replace dialog ( Ctrl + H )

    SEARCH (?-s)^.[50]0000(.+),|^\d{6}

    REPLACE ?1\1;

    Tick the Wrap around option

    Select the Regular expression search mode

    Click on the Replace All button

    Voila ! Nice isn’t it ?

    Notes :

    The search regex contains two alternatives :

    First, the (?-s) in-line modifier ensures that any . regex symbol corresponds to a single standard character, only and not to a line-break char !

    Then the part ^.[50]0000 searches for any number of six digits, beginning current line and containing a 0 or a 5 at second position, followed with four 0 digits

    And the part (.+), looks for theremainder of the lines, minus the , character, which is stored as group 1, due to the parentheses

    If current line number is not of the form ^.[50]0000, then it, necessarily, matches the second alternative :

    The part ^\d{6} matches the 6 digits number, generated by the Column Editor, which begins any line

    The replacement regex contains a conditional replacement (?#....:....) :

    If group 1 exists ( every 50,000 lines ), we rewrites the group 1, followed with a semi-colon

    If group 1 is absent, as the negative part, after a : does not exist, the first 6 digits number of any line are simply deleted

    Best Regards,

    guy038

  • Where does the background change?

    3
    0 Votes
    3 Posts
    145 Views
    Alan KilbornA

    See HERE.

  • What happened to Hyperlink?

    1
    0 Votes
    1 Posts
    180 Views
    No one has replied
  • How do i remove a duplicate line after a particular combination?

    3
    0 Votes
    3 Posts
    276 Views
    Tasos AkridoT

    Thank you, it works :)

  • Combine 2 files line by line

    20
    4 Votes
    20 Posts
    6k Views
    astrosofistaA

    Hi @Cooeeeee

    I see. The point of my post was to simplify @Fernando-Sorensen’s method, because although ingenious, it requires several steps. The basic idea was to do everything without additional windows, be it a second editor, the column editor or a search window, that would block or cut off the flow of the operation.

    The only thing that the BetterMultiSelection plugin is good for in my approach is precisely to insert the blank lines, an operation that standard multiselection cannot do - see @Alan-Kilborn’s post below - . But if the text already has blank lines interleaved, then the plugin is not necessary and, as your .gif shows, line interleaving can be done directly with standard multiselection.

    Which is the best method? For the reasons detailed above and because I have nothing against third party plugins either - in fact, I think they are a great addition to Notepad++ and heavily use them - I still prefer mine, but I have no objection to people using the one they find best.

    Thank you and, as always, have fun!

  • Takenote plugin

    4
    1 Votes
    4 Posts
    3k Views
    Michael VincentM

    @rms661 said in Takenote plugin:

    Don’t know if i can edit subject to add “Solved”, but will try

    I don’t think so, but you last post serves that purpose. Happy to help!

    Cheers.

  • 0 Votes
    6 Posts
    1k Views
    Kevin SmithK

    @PeterJones Thanks, Peter. It shouldn’t be a problem for me to just hit the collapse command again after I’ve deleted the line. The problem is it keeps surprising me. I forget it’s going to happen! The example I gave was simplistic, but when it’s two hundred lines collapsed underneath, not just two or three, everything moves on the screen and I have to find where I was editing again in order to collapse that section.

    If there is a solution, I’d love to hear it. At least this exercise has made it clearer to me what’s causing it. No doubt I’ll still forget the next time I start using Notepad++, but now it should only happen once to prompt me to note what line I’m on before hitting [Delete]!

    … Although, thinking a little more about it, if I follow your recommendation of immediately using Ctrl+Alt+F it shouldn’t matter what section the screen is showing me, it’ll collapse at the correct point! Yippie! So you have provided a solution. Many thanks. :-)

  • 0 Votes
    1 Posts
    156 Views
    No one has replied
  • Function List with comments after function name

    7
    1 Votes
    7 Posts
    767 Views
    Makwana PrahladM

    Hello,@Michael-Vincent

    Regex Explanation :

    (?i) - modifier to make the search case-insensitive
    (?<=^function) - positive lookbehind to find the position immediately preceded by the sub-string function at the start of the line
    \s+ - matches 1+ occurrences of a white-space character
    \K - forget everything matched so far
    \w+ - matches 1+ occurrences of all the characters which fall within the character class [a-zA-Z0-9_]
    Add the following parser tag to the file functionList.xml

    <parser id="mylang" displayName="mylang_syntax"> <function mainExpr="(?i)(?<=^function)\s+\K\w+" /> </parser>

    I hope this information will be useful.
    Thank you.

  • How can i sort out several letters from one word

    5
    0 Votes
    5 Posts
    292 Views
    Terry RT

    @Terry-R said in How can i sort out several letters from one word:

    or do you wish to remove/replace the found

    My bad, I see you do want to remove, so the replace function would work with the “Replace With” field left blank. Search mode would need to be “regular expression”.

    Terry

  • Compare two files and delete differences

    2
    0 Votes
    2 Posts
    2k Views
    Terry RT

    @Michael-Memphis said in Compare two files and delete differences:

    I need to match file one to file two and delete the non-matching lines

    I don’t use plugins, of which there are quite a few, and maybe one of those might have what you are looking for.

    However I would do it as follows.

    For the file with ONLY account numbers, append an a to the account number. For the file with other additional information append a b to the account number and if required copy that account number (with b) to the front of the line. Combine both files into 1 new file. Sort the file numerically. Thus an account with “a” would appear before the corresponding line from file #2 (which has a b appended to account number). Use a regular expression (regex) to remove all lines with the a appended or a b line where there is no corresponding a line. This can be completed in either 1 or 2 regexes. Also remove the appended b to clean up those lines.

    The result will be a new file #2. However the caveat is that now the file will have accounts in possibly a different order to what they were initially before combining and sorting. This can be overcome by additional steps in the process.

    You will note that I haven’t provided any regexes, as you haven’t provided any examples of how file 1 and 2 look. I’m not suggesting providing real data (possible confidentiality issues) but as the regexes can only be matched to real data we do need examples of how the data looks in order to better support you (replace some real data with dummy info of the same type). Please read the FAQ, primarily the post titled:
    FAQ Desk: Request for Help without sufficient information to help you
    Whilst this post refers more to problems running Notepad++, the use of codes to insert examples in your post will be of help.

    Terry

  • Need to turn laser gcode into plotter gcode

    2
    0 Votes
    2 Posts
    283 Views
    Alan KilbornA

    @Ann-Other said in Need to turn laser gcode into plotter gcode:

    Is it possible to make it automatic so that I give notepad the file name and it gives me back the amended file?

    What you could do is record a macro with several replacement operations in it.
    Then when you have loaded your file into N++, run the macro.

  • NP++ 7.8.8 - pt-br - issue when try tiping "í" and "é"

    1
    0 Votes
    1 Posts
    137 Views
    No one has replied
  • Problem with the latest update 7.8.7 - slow to climb to the top

    7
    0 Votes
    7 Posts
    393 Views
    Emo SerE

    @Ekopalypse

    Peace, mercy and blessings of God Almighty

    Thank you for your response

    And I apologize for the delay in responding

    In large files, I have not tried small files

    But the comment of the honorable brother above, clarifies the problem

    Thanks again

  • How do you dock the CSV Query Plugin window?

    2
    0 Votes
    2 Posts
    254 Views
    EkopalypseE

    @dsnodder

    by slowly moving the window to that position!!??

  • setting font in both views (normal and other) How?

    5
    0 Votes
    5 Posts
    987 Views
    MacNalaM

    I think we can consider this question closed. Thanks for pointing me in the right direction.

  • Combining content of files?

    16
    0 Votes
    16 Posts
    854 Views
    EkopalypseE

    @Sarah-Duong

    Yes, as I said, DeepL does not support as many languages as Google, Microsoft etc… yet.
    In my opinion, the secret of a good translation is to be as accurate as possible in your native language.
    Furthermore, I proceed in such a way that I check whether the translated text can be meaningfully retranslated.
    If so, then it will be understandable, at least I hope so.
    Example data should NEVER be translated, otherwise exactly what you have described can happen.