• Replacing a digit with exception

    21
    0 Votes
    21 Posts
    1k Views
    guy038G

    Hello, @jean-francois-trehard and All,

    In wanting to explain, my regex S/R, provided in my previous post, I realized that we should add an hypothesis :

    You must move the caret to a blank line, located before the text to be processed by the S/R

    So, let’s start with the last version :

    SEARCH (?:\$|\G)\w*?\K(?:(0)|(1)|(2))

    REPLACE (?1G)(?2H)(?3I)

    Globally, the regex (?:\$|\G)\w*?\K(?:(0)|(1)|(2)), searches, from after a literal $ symbol OR after the end of the previous search, if any, for the smallest range, even empty, of words characters, till a 0, 1 or 2 digit, then only selects this last digit and replaces it, respectively, with the G, H or I letters

    Note that the \G assertion forces the regex engine to ask itself : does the current match attempt, immediately follows the previous match ? In case of a positive answer, the current match attempt is a possible match, so far !

    As this regex only looks for consecutive words chars, it’s easy to understand why the characters, located, in the second part of a line, after the # sign, are not concerned !

    Now, if you’re still in the fog, let’s go into a little more detail and start the search, for instance, with caret on an empty line, right before the first line dc.l $02220620 ; Tile #42

    Beware, everything below is a bit “off-putting” but, in any case, it happens like that if you break the process down into smaller basic actions !

    The regex engine first searches for a range of consecutive words characters till a 0, 1 or 2 digit, either, after a literal $ or after the end of the previous search. As no search has been performed, so far, \G syntax matches, by default, at current position, the beginning of the empty line, which is a zero-length string

    As no word char exists in that empty line, the regex engine skips the EOL chars and moves to the beginning of the next line dc.l $02220620 ; Tile #42. You could say : it should match the dc string, which are word chars, also ? No, no ! Because the initial location, in the empty line, and the dc location are not contiguous. Indeed, there is a gap of the two chars : \r and \n )

    Thus, the \G assertion is not true, presently. So the regex engine tries to match the first alternative and skips to the literal $ and the next 0 digit to search for

    The \K feature cancels any match, so far and resets the regex engine working position => So, it only matches this first 0 digit. Remember that this configuration is possible as the range of chars before digit 0, 1 or 2 to search for, may be empty

    As the group 1 is defined, when matching the 0 digit, the regex engine replaces it with the string G

    Now, as no more $ symbol exists, the regex engine needs to use the second alternative, the \G assertion, which represents the location right between the letter G and the next range of word chars till a 0, 1 or 2 digit. So it just matches the first 2 digit, right after and, again, only selects that digit 2

    As the group 3 is defined when matching the 2 digit, the regex engine replaces it with the string I

    The second, third and fourth 2 digit, of current line, as well as the second 0 digit, are matched, in the same way as above, and replaced, consequently, with the appropriate letter

    Then, the regex engine matches the 62 digit, right after the previous G letter, which verifies the \G assertion and selects only the fourth digit 2 of current line, due to the \K syntax

    Again, this 2 digit is replaced with a I letter, as group 3 is defined when matching the 2 digit

    The regex engine advances one position and matches the last 0 digit of current line and replaces it with the G letter

    Now, things become interesting : the regex engine must find a next range of consecutive word chars, possibly empty, ending with, either, a 0, 1 or 2 digit. Obviously, this next range of contiguous word chars is the string 42, located some chars after the end of our previous search ! So the \G assertion is not verified anymore and, as there is no other $ symbol, either, the overall search fails. Thus, the regex engine skips the remaining chars of that first line, after the third 0 digit, which has been changed into G and moves to the beginning of the second line where the process resumes !

    And, when a line just ends with a first range of word chars, without any comments zone, it, necessarily, will search for a literal $ symbol, as the \G feature cannot be true, due to the gap produced by the EOL characters of current line !

    As you may notice, the key point, in this kind of data, is that, the several ranges of words characters are not juxtaposed. So, the \G assertion forces, automatically, the process to cancel any further search after examination of each first range of consecutive words chars of each line, following a $ symbol ;-))

    Note also that, due to the \K syntax, inside this search regex, you cannot use a step by step replacement with several clicks on the Replace button. However, you can use the Find Next button, to get the different matches

    Wow ! Glad to see that you’re still there, after these long explanations ;-)) Thank you for your patience and full attention !

    Best Regards,

    guy038

  • RegEX - Find and rename special words (letter)

    8
    0 Votes
    8 Posts
    3k Views
    guy038G

    Hi @venus642,

    Sorry, I updated my search regex to :

    SEARCH (?-s)(\$|(?!\A)\G).*?\K(?<=\w)-

    Refer to my previous post that I updated too, for the hypotheses to respect and some other pieces of information !

    BR

    guy038

  • Syntax highlighting for non-administrator users

    6
    0 Votes
    6 Posts
    357 Views
    neualexN

    @PeterJones

    I granted UserX read/write permissions to the C:\Program Files\Notepad++ folder and syntax works now.

    Thanks for your help!

  • Lua: How to have notepad + highlight the IF and END of a codeblock?

    4
    0 Votes
    4 Posts
    2k Views
    guy038G

    Hello, @themaster1124, @peterjones, and All,

    May be, using the View > Show symbol > Show Indent Guide could be useful, too ?

    Best Regards,

    guy038

  • Recovering .txt file

    6
    0 Votes
    6 Posts
    271 Views
    EkopalypseE

    @Pyrux-Deltax

    Other than what I’ve already mentioned, no, sorry.

  • Insert Date and Time Stamps

    3
    1 Votes
    3 Posts
    596 Views
    Alan KilbornA

    @amarand said in Insert Date and Time Stamps:

    I used to use TextFX under Notepad++ to insert date and time stamps - a huge time saver.

    Don’t tell me you’ve been “suffering” without your beloved timestamp insertion for an additional 2 years??

    I’d be happy to pay someone…

    We’d be happy to take your money.
    It really just would be for a list of exact step by step instructions, no real work.

  • Join lines from clipboard data

    14
    0 Votes
    14 Posts
    636 Views
    Alan KilbornA

    @guy038 said in Join lines from clipboard data:

    it seems better to always use raw strings. I mean… when using regexes, of course

    I would say this is true.

    Probably most normal Pythoners don’t use a lot of backslashes in their strings, so the simple "..." syntax works fine.

    And you certainly can use "..." with regex as well, but just remember to “double up” every backslash if you do. (But that can make your regexes a nightmare to look at).

  • 1 Votes
    2 Posts
    204 Views
    PeterJonesP

    @Patrick-Danilevici ,

    I don’t think it’s doable with just the User Defined Language lexer.

    However, if you are willing to install the PythonScript plugin, you can add extra highlighting to a User Defined Language (UDL) using regexes via the script EnhanceAnyLexer.py that @Ekopalypse shares in his github repo . So you could define the regex \w+:\w+ (you might need to do boundary assertions around it) and assign a unique color to that.

    The script is self-documenting, but if you need help installing PythonScript or figuring out how to make it all work, feel free to ask.

  • Add Charater to everyline that begins with

    3
    2 Votes
    3 Posts
    139 Views
    Clyde ParkerC

    works pretty good thank you sir!

  • Replace text inside double quotes

    4
    0 Votes
    4 Posts
    2k Views
    PeterJonesP

    @Clyde-Parker said in Replace text inside double quotes:

    Thanks for your help, i was actually looking for the regex to replace text inside quotes but i can’t do every single word working with huge files

    Yeah, you’re still not giving us enough to go on. The regex ".*?" will match text inside a quote, or ^".*?" will match only text inside a quote that begins a line, or (?<^").*?(?=") will match the text inside the quotes at the start of a line, without matching the quote marks themselves. But there is no easy way to make a map of word->replacement in the REPLACE portion of the regex.

    if you’ve got a list of 5-10 words that you HAVE, and the associated words that you WANT to convert them to, then it’s not too difficult to produce a regex that will do it. But if you’ve got hundreds or thousands of words that you want to map from one to another, you won’t be able to do it in a single manual regex.

    That said, our resident regex gurus have some tricks up their sleeves. So if you said you were able to put the list of HAVE => WANT words at the end of the file, and weren’t picky about the format for that list, someone might be able to chime in with a way to get that to miraculously transform it.

    Personally, while I find such solutions academically interesting the first time I see them, they have their limitations (if the main text file gets too long, the magic regex cannot extend all the way from the real text to the mapping at the bottom).

    Really, if I were doing this, once it got to this stage of a huge list of replacement maps, I would just write a command-line script to do it in my favorite programming language; but that’s off-topic here.

    But if I were going to solve this “inside” Notepad++, I would pull out a plugin like PythonScript: open the text to be edited in the “main” editor view and a separate file that would have the HAVE => WANT pairs in some easy-to-parse format (like HAVE => WANT or HAVE,WANT or HAVE [tab] WANT) and write some python code which would process the mapping file view line-by-line, then run the search-and-replace on the main editor view, and loop through all the changes you want to make. I’m actually pretty sure someone has shown such code in the forum before – maybe even me. But searching the forum for “PythonScript map” or some such will produce a lot of results that you’d have to wade through to find – and you might have to try variations, because everyone phrases it differently.

    Again, I highly recommend reading the advice I gave above, and trying to add enough information that someone could meaningfully give a detailed solution, rather than just my high-level “if you’re lucky, it might be doable with fancy regex, but we cannot know until you give us more detail; or it could also be done through scripting, but how exactly that will look might depend on what your data is really like, and what format your list of replacements is in”.

  • Finding multiple words inside extra quotes

    18
    0 Votes
    18 Posts
    841 Views
    TexasKCFanT

    @guy038 This solution is perfect and returns all the errors I am looking for. Thank you!

  • How does Notepad++ Manage to display all Characters and Emojis

    4
    0 Votes
    4 Posts
    5k Views
    guy038G

    Hello, @Martin-furek, @peterjones, @alan-kilborn and All,

    You may be interested by this post :

    https://community.notepad-plus-plus.org/topic/19990/regexp-fails-to-match-utf-8-characters/14

    and by this site :

    https://emojipedia.org/

    Particularly, the points :

    https://emojipedia.org/man-superhero/

    https://emojipedia.org/emoji-11.0/

    On the other hand, from this site    https://www.fontyukle.net/ara.php?ara=Segoe+UI   you could download a fairly new versions of all fonts of the Segoe UI family, listed below, with their main characteristics :

    •----------------------------------------•------------------•--------------------------------------•---------•------------•----------•------------• | Segoe UI font variations | Microsoft Name | Font Names in "Fontyukle" archives | Version | Characters | Glyphs | Kern pairs | •----------------------------------------•------------------•--------------------------------------•---------•------------•----------•------------• | Segoe UI Black (TrueType) | seguibl.ttf | Segoe UI Black.TTF | 2.02 | 2,191 | 2,443 | 2,638 | | Segoe UI Black Italic (TrueType) | seguibli.ttf | Segoe UI Black Italic.TTF | 2.02 | 2,191 | 2,544 | 8,467 | | | | | | | | | | Segoe UI (TrueType) | segoeui.ttf | Segoe UI.TTF | 5.62 | 3,952 | 5,344 | 8,292 | | Segoe UI Bold (TrueType) | segoeuib.ttf | Segoe UI Gras.ttf | 5.60 | 3,900 | 5,219 | 8,319 | | Segoe UI Bold Italic (TrueType) | segoeuiz.ttf | Segoe UI Gras Italique.ttf | 5.30 | 2,826 | 3,377 | 8,613 | | Segoe UI Italic (TrueType) | segoeuii.ttf | Segoe UI Italique.ttf | 5.30 | 2,826 | 3,377 | 5,739 | | | | | | | | | | Segoe UI Emoji (TrueType) | seguiemj.ttf | Segoe UI Emoji.TTF | 1.29 | 1,962 | 12,189 | 1,394 | | | | | | | | | | Segoe UI Historic (TrueType) | seguihis.ttf | Segoe UI Historic.TTF | 1.03 | 3,658 | 4,737 | 1,352 | | | | | | | | | | Segoe UI Light (TrueType) | segoeuil.ttf | Segoe UI Light.ttf | 5.60 | 3,902 | 5,231 | 5,503 | | Segoe UI Light Italic (TrueType) | seguili.ttf | Segoe UI Light Italic.ttf | 5.30 | 2,826 | 3,389 | 8,388 | | | | | | | | | | Segoe UI Semibold (TrueType) | seguisb.ttf | Segoe UI Semibold.TTF | 5.62 | 3,948 | 5,271 | 8,291 | | Segoe UI Semibold Italic (TrueType) | seguisbi.ttf | Segoe UI Semibold Italic.TTF | 5.32 | 2,874 | 3,437 | 5,209 | | | | | | | | | | Segoe UI Semilight (TrueType) | segoeuisl.ttf | Segoe UI Semilight.TTF | 5.62 | 3,950 | 5,219 | 8,293 | | Segoe UI Semilight Italic (TrueType) | seguisli.ttf | Segoe UI Semilight Italic.ttf | 5,30 | 2,826 | 3,389 | 8,338 | | | | | | | | | | Segoe UI Symbol (TrueType) | seguisym.ttf | Segoe UI Symbol.ttf | 6.23 | 7,362 | 9,209 | 1,361 | •----------------------------------------•------------------•--------------------------------------•---------•------------•----------•------------•

    Best Regards,

    guy038

  • Issues with dark style

    2
    0 Votes
    2 Posts
    131 Views
    EkopalypseE

    @Andrew-Truckle

    I assume this is an issue with the lexer and not the theme.
    Which lexer, aka the language like html, c++, perl …, and which theme are you using?

  • Change Font size

    3
    0 Votes
    3 Posts
    207 Views
    PeterJonesP

    I said in Change Font size:

    it’s either Ctrl+/ or Ctrl+\ on the numeric keypad

    I was unzooming today, and suddenly remembered making this comment; so I checked, and confirmed I hadn’t yet clarified that. Sorry.

    So for clarify for future readers, hold down the Ctrl key and then press the / from the numeric keypad (the keypad doesn’t have a \, so that’s not possible). Notepad++ shows that shortcut as Ctrl+Num / to make it clear that it’s the / on the numeric keypad (and I think that’s a fairly standard nomenclature).
    29d75c11-e107-4c8d-b35c-31466657c378-image.png

  • Disabled due to Store Policies error code

    5
    0 Votes
    5 Posts
    977 Views
    EkopalypseE

    @Moch-Aqib

    You have installed a forked version from the Windows Store which is NOT the official one. As far as I know, the store does not allow
    to have plugins loaded and other restrictions like the one you posted.
    If you want to use npp without these restrictions, download it from the official site here.

  • How to change character spacing?

    5
    0 Votes
    5 Posts
    4k Views
    prahladmifourP

    Hello,@Mazilla-Zim
    Please try these information, To How to change character spacing?

    To change the line spacing go to Settings → Style Configurator.

    On the left select Global Styles under Language then Brace Highlight Style under Style and then change the font size.

    I hope this information will be useful to you.
    Thank you.

  • Session Manager Load Crashing Notepad++

    2
    0 Votes
    2 Posts
    147 Views
    PeterJonesP

    @Mitchell-Ha ,

    Sorry. I could not reproduce it. It works for me.

    ----

    Why such a short reply? Because you didn’t tell us enough to be able to reproduce your problem, or because I tried what you described and got the results I expected. If you give us more information, we might be able to help more. Especially important are the ? menu’s Debug Info contents, a thorough description of the steps necessary to reproduce your problem, example text highlighted using the </> button or Markdown syntax, and possibly a screenshot of the problem (if you think it will help clarify the problem; use Windows’ Snip & Sketch or Alt+PrtScrn to capture the image, and Ctrl+V to paste it in your post).

  • automatic consecutive numbering

    12
    0 Votes
    12 Posts
    589 Views
    Andreas TröschA

    Hey guys!

    It was all good with the first script. I made a mistake by myself. You didn’t misunderstand what I was looking for. English is anyway not my native language so its more likely that I couldn’t explain it correctly. :)

    You really helped me and I can proceed with my orchestral template script!

    Thanks again.

  • Some hotkeys combination changed my typing

    3
    0 Votes
    3 Posts
    189 Views
    Grigore IG

    Thank you!
    Resolved!

  • invisible characters make difficulties -- when searching

    15
    0 Votes
    15 Posts
    506 Views
    mere-humanM

    Could someone create a corresponding issue with the suggested options, please?
    https://github.com/notepad-plus-plus/notepad-plus-plus/issues