• Replace tilde (~) with headword

    22
    0 Votes
    22 Posts
    2k Views
    glossarG

    @guy038

    Hi guy!

    Thank you for effort.

    FYI, I’ve applied this last one as well as the second one on another file. Sadly, both didn’t work well, leaving 10K-20K tildes behind.

    Greetings,
    glossar

  • Keep links and discard rest from page sourcecode.

    2
    0 Votes
    2 Posts
    203 Views
    PeterJonesP

    @Ravi-K ,

    Some questions:

    Did you intend for that to be two separate lines (ie, you want to keep both normal URLs and filenames-with-extension) or was that meant to be a single line with the filename immediately after the trailing slash in the URL? for the URL protocol, will they all be https://, or will there also be http://, ftp://, file://, irc://, or other such links? if there really are links that are filename.ext, does it have to be able to recognize any .ext, or just .jpg, or just some small set of extensions (if the last choice, please list them) The search/replace expression can be very different if there is only ever one link per line of text vs potentially needing to recognize multiple links in the same line

    If you follow the advice below and give us some more information (especially “before” and “after” data, with examples of data that will stay and data that will go), it will make it more likely that you will get an answer that meets your needs. But I will start by showing what I would do under one such circumstance

    If I were solving this problem for just https://... links, where they may or may not be more than one link per line, I would probably do it as a multi-step process

    get them onto lines by themselves: open Search > Replace dialog:
    FIND = https://[^\s()<>'"]* – assume that spaces, tabs, newlines, parentheses, angle brackets, and double or single quotes will all end a URL
    REPLACE = \r\n$0\r\n – put CRLF newlines on both sides of the matched link
    SEARCH MODE = regular expression
    REPLACE ALL Get rid of everything but those URLs-on-a-line: Search > Mark dialog (or if it is still open, just go to the Mark tab of the Replace dialog you were already in
    FIND = ^https://[^\s()<>'"]*$
    BOOKMARK LINE = enabled
    MARK ALL
    Search > Bookmark > Remove unmarked lines

    Given the number of open questions about your data, I doubt that will immediately solve your problem. But it would be my first step. I recommend figuring out how all the pieces of my recommendation worked, and trying to tweak them to match your actual data. If you have trouble, follow the advice below, share what you tried and why you thought it would work when you tweaked my regular expressions, and ask specific questions.

    ----

    Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual Markdown syntax. To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

  • How to find identical files saved under different names?

    6
    0 Votes
    6 Posts
    707 Views
  • Regex: Select/Delete html <div> tags between comments

    15
    1 Votes
    15 Posts
    992 Views
    Robin CruiseR

    @guy038 , @PeterJones and @Alan-Kilborn

    Thank you. Now, it was much easy for me to understand the structure of a the new way of using regex.

    I hope that all those who will access this page in the future will take a step forward towards progress in the way of how regex works.

  • Macro Save/Reload/Where Files

    9
    0 Votes
    9 Posts
    10k Views
    PeterJonesP

    @PorAhiViene-Pepe said in Macro Save/Reload/Where Files:

    C:\Users\<localaccount>\AppData\Roaming\Notepad++

    Please note: that assumes a standard Windows setup. One can tell Windows to place that folder in a different location. The environment variable %AppData% 🛈 encodes the right path for the ...\AppData\Roaming folder, so %AppData%\Notepad++, like @Ekopalypse said a couple years ago, and @Bharath-k said a few months back, is going to access the right spot, no matter how Windows is configured, and without having to edit the path: you can just paste %AppData%\Notepad++ into the Windows Explorer or File>Open address bar, and always get to the right place
    9223894d-5e52-4a26-9cfc-a6124b934689-image.png
    03ecf6eb-4916-4844-bca6-3e478656ab43-image.png

  • 1 Votes
    2 Posts
    1k Views
    PeterJonesP

    @PorAhiViene-Pepe ,

    Thanks for sharing that.

    I have a feeling your regex got munged by the forum, because <.?>|</.?> only looks for 0-or-1-character between the angle-brackets; I assume the . were really .*?

    For future reference, in this forum, you can put ` marks around text (like regex) to format it red like my examples and to make sure the forum doesn’t munge the characters. `<.*?>|</.*?>` will render as <.*?>|</.*?> , so that we can see the actual regex as you intended (and that has the benefit of not wondering if the “smart quotes” were part of the regex, or just used to separate the regex from the flow of your text)

  • Removing all lines that don't contain multiple texts in multiple files

    8
    0 Votes
    8 Posts
    380 Views
    Terry RT

    @guy038 said in Removing all lines that don't contain multiple texts in multiple files:

    In order to identify nice regex S/R, we should, globally, take execution time and number of steps in account, more often !

    @guy038, I commend you for your in depth study of the effect of lazy and greedy quantifiers on execution times. It’s good to know that it did back up my theory. I suppose I hadn’t; until this time; actually spent much time in considering the effect, but actually I had subconsciously been applying the theory anyway.

    When you say “Note the irony of such a sentence: we need a lazy quantifier for faster execution ;-))” I think that it is actually quite self explanatory.

    I suppose I’ve thought that a greedy quantifier must still process the line 1 character at a time until the end of the line is reached (unless there is some magical way it can grab instantly ALL characters on a line), just doing an end of line test (I’m only talking (?-s) option). Then it must process 1 character at a time in reverse for the actual regex match it is looking for. The lazy quantifier JUST processes 1 character at a time proceeding across the line until the match is found.

    It’s possible (as I stated earlier) that the (.*) might be an extremely fast process, but even if the match string is evenly positioned across a line there (to my mind) would still be some processing overhead for a greedy quantifier with respect to a lazy one. At this point I’m actually being contrary to a previous statement I made:
    “As mine will “avoid” a line that DOES have the match (and therefore stays) in 7 character checks, your greedy regex will take more character checks on a long line, and less on a short line.”
    I now think that a greedy quantifier will ALWAYS make more tests (steps) in processing the same line, regardless of whether there is a match or not.

    And @Alan-Kilborn , indeed you are right to some degree, all this doesn’t matter for most OPs. But I only have to turn to the many topics on which many of the seasoned members have contributed ever increasing tighter code as alternative answers to OP questions. One might show an answer, then another picks that regex apart, see what makes it tick and realises there are some efficiencies to be made and presents an updated version. Now with @guy038’s tests we can see yet another tool we can add to our toolbox, the consideration that a lazy quantifier isn’t so lazy after all.

    Cheers
    Terry

    PS and sorry to you @guy038 for your problems with XP not being able to use the regex101 site. I will have to say though the old addage “flogging a dead horse” comes to mind.
    https://en.wikipedia.org/wiki/Flogging_a_dead_horse

  • regexp search match string inside

    3
    0 Votes
    3 Posts
    172 Views
    guy038G

    Hi, @patrickdrd, @alan-kilborn and All

    To select from the last string ΒΕ of the lines ( Greek letters ! ) till the string *00, use the regex (?-s).+\KΒΕ.+\*00

    To select from the first string ΒΕ of the lines ( Greek letters ! ) till the string *00, use the regex (?-s).+?\KΒΕ.+\*00

    Note that, if the string *00 ends each line of your file, you can simplify these regexes as, respectively, (?-s).+\KΒΕ.+ and (?-s).+?\KΒΕ.+

    Best Regards,

    guy038

  • Find string of text and copy that line twice underneath

    4
    0 Votes
    4 Posts
    252 Views
    Saar De LongieS

    Hi Peter,

    Thanks a lot for your input! Very much appreciated.
    I know now where to go to find a solution.
    Up to the company for which I’m temping right now, to talk to their provider.
    PS I was not hired for the job to develop coding, but it would make my life a lot easier :)

    Kind regards,
    Saar

  • Search multiple strings in all opened files

    9
    0 Votes
    9 Posts
    391 Views
    prahladmifourP

    Hello,@Сергей-Бычков
    Please follow this information, To Search multiple strings in all opened files.

    Go to Search > Find in Files (Ctrl+Shift+F for the keyboard addicted) and enter:

    1.Find What = (test1|test2)
    2.Filters = *.txt
    3.Directory = enter the path of the directory you want to search in. You can check to Follow the current doc. to have the path of the current file to be filled.
    4.Search mode = Regular Expression

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

  • Bug Report - Persistent search criteria when opening a file

    3
    0 Votes
    3 Posts
    212 Views
    Alan KilbornA

    @Terry-R said in Bug Report - Persistent search criteria when opening a file:

    I will say however that I ran through the steps you posted and did NOT find any issue. The search field did NOT retain a previous filter, however it will show previous filters as a dropdown once I started typing there.

    Agree 100% with Terry. No issue.

  • Replace (to change links)

    4
    0 Votes
    4 Posts
    281 Views
    Xen le CamX

    It works! It’s fantastic… and magic!
    Thanks very much indeed, for the solution and the comment: very good!

  • export plugin from older version

    20
    0 Votes
    20 Posts
    1k Views
    PeterJonesP

    @Michael-Vincent ,

    And another confirmation from me. That’s probably the OP’s issue for the context menu.

  • The Vietnamese language doesn't show up correctly after saving

    36
    1 Votes
    36 Posts
    3k Views
    PeterJonesP

    @Nick-Boescht said in The Vietnamese language doesn't show up correctly after saving:

    Everything went great!

    I assume this means the problem is solved for you. At least for now.

    However, I am going to give future advice on this problem in case there are others with similar difficulties, or if you have more problems. As such, I will make one more comment on an earlier statement, then outline what I understand so far. If I have stuff wrong, you’ll have to correct me either now or in whenever you need our help again.

    This is what I see

    But it’s not all I asked for. You did not show the status bar. Which is still making us guess. Or assume that you have correctly understood what we’ve been asking

    If you give a detailed, step by step explanation of exactly what you are doing, you can save a lot of the back-and-forth we’ve had to go through to get to this point.

    The process I understand you are doing:

    use some extractor tool to extract XML from a game’s binary db file open the xml in Notepad++ the file automatically opens in encoding _____ : I think it’s either opening as Win-1251 or some other western-european encoding instead of Win-1258… but I’m not sure, because you’ve been too vague) – but characters are not showing up right. Or maybe, if you’ve really set everything like @Ekopalypse showed, it was opening as UTF-8. You manually selected Encoding > ____ (I assume Win-1258), and it appeared correct. So you saved. When you exit and reload, it once again comes up in the same encoding as in step#3.

    If this is not your process, you’ll need to correct it before we can give you more help.

    Back to the problem at hand: I don’t actually do a lot of encoding-based text editing (except when I help others in this forum), as I’m in simple circumstances. But in what I’ve picked up over the years: if at all possible, it’s best to use UTF-8 or another unicode encoding – that’s been the right way of doing things since the 90s when Unicode was invented, and should have been more encouraged since the turn of the century once UTF-8 started gaining in popularity. The fact that any modern tool (game, what have you) is still using old 256-codepoint Win-#### encodings shows the complete lack of understanding on the part of those developers.

    Unfortunately, without a unicode encoding, then Notepad++ is left with two options: guess the encoding based on the frequency of particular bytes with values between 128 and 255, or use a default setting. The guessing is often wrong, and using a default setting can make things even worse (especially if you’re dealing with a mix). This is because Windows (based on 1980’s pre-unicode DOS) didn’t store encoding information or other file meta-data in the directory table or any other file meta-data location, so it was up to applications to decide what to do with any particular sequence of bytes found in a disk file.

    In this situation, I would err on the side of use-the-default-setting, then when it’s wrong, manually change the encoding – if you are frequently going to use Win-1258, then use Settings > Shortcut Mapper, set filter: 1258, and assign a keyboard shortcut to Win-1258, so from then on, you can just hit that keyboard shortcut to set that encoding.

    But actually, I might try the experiment of changing the xml encoding line to <?xml version="1.0" encoding="utf-8">, and do an Encoding > Convert to UTF-8 on the file. That way, when Notepad++ applies the reasonable default of UTF-8 to 8bit files, it will Do What You Mean. After saving it as UTF-8, it should maintain the right encoding from then on in Notepad++… and you should try to see if the game will accept an XML config file encoded in UTF-8. If not, complain to the game company that they don’t care about non-western languages, and see if you can convince them to accept utf-8 and other unicode-based encodings.

  • Match < and > and what's between it

    12
    0 Votes
    12 Posts
    3k Views
    guy038G

    Hi, @alan-kilborn and All,

    Yes, these two drop-down lists help us to compare if a specific functionality is supported or not, between two regex engine flavours, as well as some specificities for each one !

    Note that my last sentence, between parentheses ( $0 vs $1 ) is not connected at all, with these two drop-down lists, but, simply, refers to subjects asked by @glossar !

    BR

    guy038

  • Replace all occurrences of a character between 2 words

    22
    1 Votes
    22 Posts
    2k Views
    Alan KilbornA

    @guy038 said in Replace all occurrences of a character between 2 words:

    Indeed, as meta-characters, the [ and ] must be escaped with the \ symbol to search them as literal symbols. But the [ syntax has also a special meaning, with the NodeBB Markdown language !

    Given these problems (that we usually initially forget when posting), I may consider going with this substitution instead, for any future regexes I post containing the dreaded backslash-bracket situation:

    for backslash-open-square-bracket: \x5B
    for backslash-close-square-bracket: \x5D

    Or…maybe not. :-)

  • Macro script when txt content changes

    20
    0 Votes
    20 Posts
    1k Views
    Mirko RossiM

    @Ekopalypse said in Macro script when txt content changes:

    You start the script via the PythonScript menu, BUT only once. If you call it multiple times, the macro will be called the same number of times. I should have mentioned that before, sorry.

    ahahah you are right :) The title and the interpreter are reversed twice … I should have guessed it.

    It seems to work perfectly.
    now, I just have a txt encoding problem but that goes beyond this post

    thank you all

  • Either find or skip comma(s) inside parentheses

    4
    0 Votes
    4 Posts
    302 Views
    guy038G

    Hello, @glossar, @terry-r and All,

    Some other regexes !

    To match any non-empty single-line area, between ( and ) included, not containing any ,, use the regex

    \([^(),\r\n]*\)

    To match any non-empty single-line area, between ( and ) included, containing, at least, one ,, use the regex

    (?-s)\([^(),\r\n]*,.+?\)

    To match any non-empty single-line area, between ( and ) not included, not containing any ,, use the regex

    \(\K[^(),\r\n]*(?=\))

    To match any non-empty single-line area, between ( and ) not included, containing, at least, one ,, use the regex

    (?-s)\(\K[^(),\r\n]*,.+?(?=\))

    Best regards,

    guy038

  • Paste every "say 37th line" apx..

    30
    0 Votes
    30 Posts
    2k Views
    Alan KilbornA

    @guy038

    Ok, Guy is putting on a “clinic”, in this case for “All”.
    In that case, “Nice Job!”

  • popup when cursor is placed within text

    2
    0 Votes
    2 Posts
    265 Views
    Alan KilbornA

    @Al-Kiecker

    Auto-completion popup, perhaps?

    Try the Settings menu and then select Preferences…. Then seek out Auto-Completion :

    ffc6c660-fb78-4039-bd65-f8c3e4b2e90f-image.png