• Parenthesis (<curved brackets>) won't appear when 'Replacing'.

    8
    1 Votes
    8 Posts
    610 Views
    Alan KilbornA

    @Terry-Gaff-0

    Ah, it didn’t hit me that your macro uses Replace and not Replace All (until I looked up the 1608 in Peter’s link above).

    With Replace you could very well intend to run it twice in succession, in which case those “6 lines” would be duplicated in the recorder data.

    It all depends upon what you are actually doing (which we don’t have a good grasp on). We trust that YOU know what you are doing. :-)

  • adding incremental number between ' '

    2
    0 Votes
    2 Posts
    163 Views
    guy038G

    Hello, @speedrider and All,

    Here is my solution :

    From your text :

    '13': type: SHOP id: SPRUCE_WOOD buy-price: 200.0 '14': type: SHOP id: BIRCH_LOG buy-price: 200.0 '15': type: SHOP id: BIRCH_WOOD buy-price: 200.0 '16': type: SHOP id: JUNGLE_LOG buy-price: 200.0 '17': type: SHOP id: JUNGLE_WOOD buy-price: 200.0 '18': type: SHOP id: ACACIA_LOG buy-price: 200.0 '19': type: SHOP id: ACACIA_WOOD buy-price: 200.0 '20': type: SHOP id: DARK_OAK_LOG buy-price: 200.0 '21': type: SHOP id: DARK_OAK_WOOD buy-price: 200.0 '22': type: SHOP id: SPONGE buy-price: 260.0 '23': type: SHOP id: BRICKS buy-price: 270.0 '24': type: SHOP id: WHITE_WOOL buy-price: 320.0

    Do this regex S/R :

    SEARCH \R(?!\h*')|('\d+')

    REPLACE ?1'':|

    Select the Regular expression search mode

    You should get this text :

    '':| type: SHOP| id: SPRUCE_WOOD| buy-price: 200.0 '':| type: SHOP| id: BIRCH_LOG| buy-price: 200.0 '':| type: SHOP| id: BIRCH_WOOD| buy-price: 200.0 '':| type: SHOP| id: JUNGLE_LOG| buy-price: 200.0 '':| type: SHOP| id: JUNGLE_WOOD| buy-price: 200.0 '':| type: SHOP| id: ACACIA_LOG| buy-price: 200.0 '':| type: SHOP| id: ACACIA_WOOD| buy-price: 200.0 '':| type: SHOP| id: DARK_OAK_LOG| buy-price: 200.0 '':| type: SHOP| id: DARK_OAK_WOOD| buy-price: 200.0 '':| type: SHOP| id: SPONGE| buy-price: 260.0 '':| type: SHOP| id: BRICKS| buy-price: 270.0 '':| type: SHOP| id: WHITE_WOOL| buy-price: 320.0|

    Now place the caret between the first '' zone

    Open the Column editor ( Alt + C ) and renumber as you like

    Don’t forget to tick the Leading zeros option

    For instance, we could end with this text :

    '01':| type: SHOP| id: SPRUCE_WOOD| buy-price: 200.0 '02':| type: SHOP| id: BIRCH_LOG| buy-price: 200.0 '03':| type: SHOP| id: BIRCH_WOOD| buy-price: 200.0 '04':| type: SHOP| id: JUNGLE_LOG| buy-price: 200.0 '05':| type: SHOP| id: JUNGLE_WOOD| buy-price: 200.0 '06':| type: SHOP| id: ACACIA_LOG| buy-price: 200.0 '07':| type: SHOP| id: ACACIA_WOOD| buy-price: 200.0 '08':| type: SHOP| id: DARK_OAK_LOG| buy-price: 200.0 '09':| type: SHOP| id: DARK_OAK_WOOD| buy-price: 200.0 '10':| type: SHOP| id: SPONGE| buy-price: 260.0 '11':| type: SHOP| id: BRICKS| buy-price: 270.0 '12':| type: SHOP| id: WHITE_WOOL| buy-price: 320.0|

    Now, use this simple regex S/R to get your initial list :

    SEARCH \|

    REPLACE \r\n for Windows files    OR    \n for Unix files

    '01': type: SHOP id: SPRUCE_WOOD buy-price: 200.0 '02': type: SHOP id: BIRCH_LOG buy-price: 200.0 '03': type: SHOP id: BIRCH_WOOD buy-price: 200.0 '04': type: SHOP id: JUNGLE_LOG buy-price: 200.0 '05': type: SHOP id: JUNGLE_WOOD buy-price: 200.0 '06': type: SHOP id: ACACIA_LOG buy-price: 200.0 '07': type: SHOP id: ACACIA_WOOD buy-price: 200.0 '08': type: SHOP id: DARK_OAK_LOG buy-price: 200.0 '09': type: SHOP id: DARK_OAK_WOOD buy-price: 200.0 '10': type: SHOP id: SPONGE buy-price: 260.0 '11': type: SHOP id: BRICKS buy-price: 270.0 '12': type: SHOP id: WHITE_WOOL buy-price: 320.0

    Voila !

    Best Regards,

    guy038

  • How to copy or extract particular string value from each line ?

    11
    0 Votes
    11 Posts
    5k Views
    guy038G

    Hi, @ekopalypse, @sagar-kurapati, @alan-kilborn and All,

    @ekopalypse, you’re perfectly right about it ! I’m probably going to add a remark in my previous post !

    Indeed, if I move the caret to a line containing a MD5 signature, without the restrictive condition that it must also contain the string POST/items/update-batch, my regex wrongly matches it :-((

    The problem is that, after moving caret to any position, the regex engine thinks that this location is the very start of the text. It’s a general drawback of the powerful \G behavior !

    Normally, the regex engine always tries, first, the first alternative of regex C, because of the (?-s) modifier and because of line-breaks in text. Indeed, the second alternative is never tried, first, as possible matches cannot be contiguous

    So the 1st part matches, for instance, the string OST/items/update-batch4311bbbeca82649427b192c7b868133c. Then the 2nd alternative \G.+?\K[[:xdigit:]]{32} matches the contiguous area, made of the smallest range of any standard char till an other MD5 signature and so on till the end of current scanned line

    Then, because of the line-break chars, the next match cannot be contiguous, implying, necessarily, that the next match will be satisfied by the first alternative, only !

    A solution would be to :

    Firstly mark all the lines containing the string OST/items/update-batch with a special symbol, ending each line

    Secondly, search for any MD5 signature, ONLY IF current line ends with that special symbol

    Thirdly delete this special symbol, as well

    But, I haven’t found out a fair regex to suppress this drawback, yet !

    To conclude, I think that the only sensible solution is to move the caret to the very beginning of file, which does not match, most of the time, the regex pattern located after the \G syntax ;-))

    Best Regards,

    guy038

  • Can I replace character with linefeedchracater in Notepad++ ?

    7
    0 Votes
    7 Posts
    337 Views
    PeterJonesP

    @PeterJones said in Can I replace character with linefeedchracater in Notepad++ ?:

    Let’s see how it renders after posting…

    baa88330-f1b9-45cf-9976-70e53c601375-image.png

    Looks like \\[ and \\] have special meaning in the forum’s markdown’s backtick implementation. Weird.

  • Totally botched view of an .rtf file

    7
    1 Votes
    7 Posts
    758 Views
    David GalbraithD

    Well, I guess it’s not the Fault of NPP. I even opened it up in Word and removed all formatting and tried again. Didn’t help. I’ll just have to create a new rtf file and copy the text over and then replace all of my copies with the new rtf file. Thanks for being so helpful. :)

  • Hunspell

    6
    0 Votes
    6 Posts
    723 Views
    Thomas 2020T

    I think you are probably going to have to type more than 5-8 words in a posting in order to get your point across.

    The shorter the sentences, the more easily the translator translates.

    Ignored only for current session.
    This means it will reappear the next time it is edited.

    I can’t convert pl_PL.dic to a dictionary and convert again to pl_PL.dic.

  • Delete line with duplicate Number

    6
    0 Votes
    6 Posts
    475 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
    436 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
    902 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
    106 Views
    Alan KilbornA

    See HERE.

  • What happened to Hyperlink?

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

    3
    0 Votes
    3 Posts
    189 Views
    Tasos AkridoT

    Thank you, it works :)

  • Combine 2 files line by line

    20
    4 Votes
    20 Posts
    5k 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
    750 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
    117 Views
    No one has replied
  • Function List with comments after function name

    7
    1 Votes
    7 Posts
    499 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
    209 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