• Regex Custom UDL Parser

    7
    2 Votes
    7 Posts
    442 Views
    Khundian TwitchK

    @PeterJones

    You’re a star! That looks awesome!
    If you’re ever in Belgium I owe you some beers! :)

  • Why Carets?

    6
    0 Votes
    6 Posts
    854 Views
    Dave RowlandsD

    According to Encyclopedia MDPI

    The caret was originally and continues to be used in handwritten form as a proofreading mark to indicate where a punctuation mark, word, or phrase should be inserted into a document.[1] The term comes from the Latin caret, “it lacks”, from carēre, “to lack; to be separated from; to be free from”

  • How to sort data by number in ascending order - within specific ranges

    2
    0 Votes
    2 Posts
    234 Views
    guy038G

    Hi, @marcos-miguel and All,

    well…, just use the built-in N++ sort feature !!

    So, select your text :

    CITY Total London 5 London 3 London 4 London 1 London 2 NYC 40 NYC 30 NYC 50 NYC 70 NYC 60

    Use the Edit > Line Operations > Sort lines Lexicographically Ascending option

    And you get your expected text :

    CITY Total London 1 London 2 London 3 London 4 London 5 NYC 30 NYC 40 NYC 50 NYC 60 NYC 70

    Best regards,

    guy038

  • Npp v8.6 cursor oddity with copy paste into a 2x0 column

    4
    1 Votes
    4 Posts
    311 Views
    mkupperM

    I did more testing and discovered that the version of misbehavior that @Coises observed also happens with npp 8.3.3 and 8.5.8 and thus it’s no longer just a npp 8.6 issue. I experimented more and discovered the reason my installed copy of npp shows the behavior right away, instead of when I switch tabs is that I had:

    My plugins\config\PythonScriptStartup.cnf has SETTING/STARTUP/ATSTARTUP My plugins\config\PythonScript\scripts\startup.py has: from Npp import editor, editor1, editor2, SCINTILLANOTIFICATION, INDICATORSTYLE def revert_url_indicator(args): editor1.indicSetHoverStyle(8, INDICATORSTYLE.TEXTFORE) editor2.indicSetHoverStyle(8, INDICATORSTYLE.TEXTFORE) editor.callbackSync(revert_url_indicator, [SCINTILLANOTIFICATION.UPDATEUI]) Apparently as the UI gets updated Python is sweeping through all of the tabs which is why for me I did not need to switch to another tab and back to trigger the behavior I reported. That scriptlet came from this forum thread in July 2020.
  • Wanting to change every other time a word comes up.

    8
    1 Votes
    8 Posts
    321 Views
    no hanksN

    @Alan-Kilborn

    Sorry that one was on me, im still new at using notepad++ and wasn’t sure how to word my question. I do again apricate your effort.

  • Syntax Highlightning for folder path in custom language

    2
    0 Votes
    2 Posts
    188 Views
    PeterJonesP

    @Mad-Rheeza ,

    The User Defined Lanauge (UDL) system is not that powerful on its own.

    If you use the EnhanceAnyLexer plugin, you can use a regular expression to define it.

    But good luck in coming up with a regex that can distinguish between two similar (or identical) sets of text which mean two different things:

    I want to rename c:\path\filename as blah.txt I want to rename c:\path\filename as blah.txt

    In the first instance, it’s really implying “I want to rename c:\path\filename as blah.txt” to mean a single filename with spaces. The second is really implying “I want to rename c:\path\filename as blah.txt”

    And by “good luck”, I meant, “that’s an impossible task, without caveats”.

    If you have the caveat of “each line that starts with a drive letter then a colon then forward-or-backward-slash is a single filename, which may or may not include spaces, all the way to the end of the line”, then it’s easy. Something like ^[A-Z]:[\\/].*?$ will handle that.

    Or if you defined that all filenames with spaces must have double-quotes around (like the cmd.exe prompt and Windows > Run dialog require), then it’s also not too bad: Something like [A-Z]:[/\\]\S+|"[A-Z]:[/\\].+?" might work (the left half of the alternation before the | is for filenames without spaces, and the right half is for filenames in quotes, which might contain spaces.

    Or if you always have a three-letter extension, then [A-Z]:[/\\].*\.[A-Za-z]{3} would likely work.

  • UCS-2 encoding option missing

    3
    1 Votes
    3 Posts
    898 Views
    Alexis GuerinA

    @PeterJones

    Thanks for your answer.

  • Proper syntax for \s (spaces) in replace expression

    17
    0 Votes
    17 Posts
    3k Views
    Alan KilbornA

    @guy038 said in Proper syntax for \s (spaces) in replace expression:

    REPLACE ( )

    There are two space chars between the parentheses !

    Tricky. :-)
    The parens are only used because the OP was “uncomfortable” with whitespace he couldn’t really see in the Replace with box.

  • 1 Votes
    2 Posts
    492 Views
    PeterJonesP

    @victor-sahag ,

    My first guess is that your theme doesn’t include the definitions – which may have happened if you had an installation from before v8.5.1 (which added MS T-SQL), then upgraded to a newer version (like the v8.5.8 that you show), or if you’re using one of the themes that hasn’t been updated (“mssql” is only present in stylers.xml or DarkModeDefault.xml)

    Starting from a fresh Notepad++ v8.5.8 portable, it does syntax highlight MS T-SQL
    9dd4dae3-7230-445a-b960-f7625857c1b0-image.png

    So if you go to Settings > Style Configurator and do not see the MS T-SQL in the list of Languages on the left, you can grab that section from your installed directory’s stylers.model.xml: copy the mssql section (<LexerType name="mssql" desc="MS T-SQL" ext="">...</LexerType>) and paste it into the installed version of your theme (either %AppData%\Notepad++\stylers.xml for the default theme, or for other themes, go to %AppData%\Notepad++\themes\ThemeName.xml if you have a personal copy or <install_dir>\themes\ThemeName.xml if you just have the installed copy of the theme), then save the file and restart Notepad++. After that, MS T-SQL should be in your Style Configurator, and it should syntax highlight. If the colors don’t match with your theme, you will need to update the colors using the Style Configurator to make it look more like the other languages in your chosen theme.

  • Merging xml files

    2
    0 Votes
    2 Posts
    691 Views
    Alan KilbornA

    @Bela-Barton

    Unless there’s a way to do it with the XMLTools plugin (which I doubt), then this question is off-topic for this forum.

  • Color User defined global variable words e.g. TEST=

    7
    0 Votes
    7 Posts
    500 Views
    PeterJonesP

    @Christopher-Rotolo said in Color User defined global variable words e.g. TEST=:

    If I wanted to ‘request an update’ to the smalltalk language, any idea what is my best route

    The Lexilla project has an issues page, which is where official feature requests for the Smalltalk lexer would go.

    Again, given that they haven’t updated the Smalltalk lexer in 18 years, I am doubtful that they will add any new features to the lexer; but I have been wrong about such guesses before.

  • Regex: Delete group of many \\ on the same line

    3
    0 Votes
    3 Posts
    234 Views
    mkupperM

    @Hellena-Crainicu I suspect the reason your first expression did not work is that you may have Windows end-of-line with \r\n rather than the Unix style \n end-of-line that your expression expected. If you use \R then it will match any style of end of line. \R works with Windows, Unix, and Macintosh style end of lines which use \r.

    If you replaced the \n with \R we have \\\\u[0-9a-fA-F]{4}.*?\R{2,}

    That will match from the first \\uxxxx on to the end of the line followed by two or more end of line marks. The expression matches your example data if it’s followed by two or more blank lines.

    In your follow-up you used \\\\.*$ implying you had not intended to also include the end-of-line marks as part of the pattern nor the followed-by-blank-line requirement.

    This will work \\\\u[0-9a-fA-F]{4}.*$ though as you probably noticed, the data also includes \\ sequences such as \\n which is a newline plus some unusual things such as \\ n with a space between the \\ and n. The underlying HTML that this is intended to decode to is badly formatted meaning it’s likely not worthwhile to fully parse the data.

    Your \\\\.*$ just gets rid of it which is probably good.

  • Regex: Delete all the instances of <title> html tag, except the first one

    8
    0 Votes
    8 Posts
    343 Views
    mkupperM

    @Hellena-Crainicu I was puzzled by your comment. I suspect you were testing by having the expression you were testing with at the top of the file. In that case the first title was in the expression itself.

    I modified my search expression slightly to replace < with \x3c so that we can have the search/replace expression within the file for testing. I put it at the bottom in these examples.

    Here is the test I ran:

    Original data <p>但是减脂期可不一定就意味着每天只吃水煮鸡胸和水煮西蓝花,完全苦行僧一样的生活。如果在营养均衡的三餐之间适当的尝试一些健康的小零食,不仅能为减脂期提供动力和新鲜感,还可以为生活增添不少的趣味呢。</p>除此之外,从营养学角度,适当的加餐可以预防三餐之间出现低血糖的现象,还能防止因为饥饿而在下一餐中暴饮暴食,摄入过多热量的情况发生。</p>因此,健康的小零食不仅有助于完成减脂目标,还能让你的减肥期丰富多彩,何乐而不为呢?下面就来推荐给大家10种好吃又健康的小零食。</p> <title>用正确方式打开 MyGainer增健肌粉! - MYPROTEIN™</title> blah bhla blah bhla <title>Home is me</title> blah bhla <title>Payton is your name</title> Search: (?s)(\x3ctitle>.*?\x3c/title>.*?)\x3ctitle>.*?\x3c/title> Replace: $1

    ###First pass
    This is after doing search-replace-all one time. It removed the second title that was on line 5.

    <p>但是减脂期可不一定就意味着每天只吃水煮鸡胸和水煮西蓝花,完全苦行僧一样的生活。如果在营养均衡的三餐之间适当的尝试一些健康的小零食,不仅能为减脂期提供动力和新鲜感,还可以为生活增添不少的趣味呢。</p>除此之外,从营养学角度,适当的加餐可以预防三餐之间出现低血糖的现象,还能防止因为饥饿而在下一餐中暴饮暴食,摄入过多热量的情况发生。</p>因此,健康的小零食不仅有助于完成减脂目标,还能让你的减肥期丰富多彩,何乐而不为呢?下面就来推荐给大家10种好吃又健康的小零食。</p> <title>用正确方式打开 MyGainer增健肌粉! - MYPROTEIN™</title> blah bhla blah bhla blah bhla <title>Payton is your name</title> Search: (?s)(\x3ctitle>.*?\x3c/title>.*?)\x3ctitle>.*?\x3c/title> Replace: $1

    ###Second pass
    This is after doing search-replace-all twice. The first pass removed second title that was on line 5 and the second pass removed the third title that was on line 7.

    <p>但是减脂期可不一定就意味着每天只吃水煮鸡胸和水煮西蓝花,完全苦行僧一样的生活。如果在营养均衡的三餐之间适当的尝试一些健康的小零食,不仅能为减脂期提供动力和新鲜感,还可以为生活增添不少的趣味呢。</p>除此之外,从营养学角度,适当的加餐可以预防三餐之间出现低血糖的现象,还能防止因为饥饿而在下一餐中暴饮暴食,摄入过多热量的情况发生。</p>因此,健康的小零食不仅有助于完成减脂目标,还能让你的减肥期丰富多彩,何乐而不为呢?下面就来推荐给大家10种好吃又健康的小零食。</p> <title>用正确方式打开 MyGainer增健肌粉! - MYPROTEIN™</title> blah bhla blah bhla blah bhla Search: (?s)(\x3ctitle>.*?\x3c/title>.*?)\x3ctitle>.*?\x3c/title> Replace: $1

    If you watch the status line at the bottom of the search/replace box you will see:

    After pass 1: Replace All: 1 occurrence was replaced in entire file After pass 2: Replace All: 1 occurrence was replaced in entire file After pass 3: Replace All: 0 occurrences were replaced in entire file

    While your examples had the titles on their own lines I had coded to allow them to be anywhere in a line and for them to span lines as that’s what HTML allows. If you want to only support titles on a line by itself then we can add some anchoring:
    Search: (?s)^(\x3ctitle>.*?\x3c/title>\R.*?\R)\x3ctitle>.*?\x3c/title>$
    Replace: $1

    Even that is not perfect as it allows titles to span or more lines. If you insists on only matching titles on one line and not to span them then toggle the dot/EOL spanner flag:
    Search: ^(\x3ctitle>(?-s).*?\x3c/title>\R(?s).*?\R)\x3ctitle>(?-s).*?\x3c/title>$
    Replace: $1

    As you can see, the expression is getting more complicated to deal with the edge cases and requirements.

  • I needed a help in something

    10
    1 Votes
    10 Posts
    691 Views
    guy038G

    Hello, @mohammad-Al-Maaitah, @terry-r, @Peterjones and All,

    If we suppose that each line does NOT contain two or more colon chars ( : ), then the simple regex syntax, below, should be enough :

    SEARCH (?-s)^.{5,}:.*\R?

    REPLACE Leave EMPTY

    If several colon chars may exist in one line, we would have to distinguish between multiple cases ! But, this is on other story !

    Best Regards,

    guy038

  • Replace with - question for advance formating

    3
    1 Votes
    3 Posts
    188 Views
    D

    @Coises Thank you - it did the work perfectly!

  • How do I search for multiple names at once? Notebad++

    9
    1 Votes
    9 Posts
    656 Views
    mkupperM

    @sabry-farg
    Using regular expression mode you search for

    ahmed|saeed|emad|sameer

    The | symbol is usually on keyboards above the enter key. It’s known as vertical line, vertical bar, or pipe symbol. It has a rather long article on Wikipedia. https://en.wikipedia.org/wiki/Vertical_bar

    Nearly always we will see this in parentheses such as:

    (ahmed|saeed|emad|sameer)

    which then makes the name available when doing a search/replace using either \1 or $1

  • Duplicate Each Block of Lines Consecutively

    3
    2 Votes
    3 Posts
    1k Views
    M

    @PeterJones Thanks for the solution! I really appreciate that. So it turns out that I can use regex to do it. I’m embarassed that my regex skill hasn’t improved much. It seems to decline instead after long hiatus. If time allows, I want to relearn it so that I don’t have to keep asking here.

  • bypass admin

    2
    0 Votes
    2 Posts
    333 Views
    PeterJonesP

    @Benjamin-Zimmerman ,

    The portable edition, which can be unzipped and run into any directory where you have write permission, can be used with no admin access needed.

    But please note that I am not advocating violating your company’s IT policies: if you are not allowed to install or use software that hasn’t been approved by your IT department, then don’t.

  • Macros not saving

    13
    2 Votes
    13 Posts
    1k Views
    Robert RothR

    @mkupper Whelp, that fixed it. Once I replaced it with the former tmp, it worked just fine, and I’m able to modify macros.

    Still not quite sure why this was the case, but this definitely is a simpler test/fix than making a copy of the entire directory.

    Thanks, everyone, for the assistance.

  • Mark with same function jumping to row as Find?

    7
    0 Votes
    7 Posts
    398 Views
    Alan KilbornA

    @PeterJones said in Mark with same function jumping to row as Find?:

    But Mark with the ☑ Bookmark Line option turned on will also bookmark the lines, then F2 (Search > Bookmark > Next Bookmark) will navigate you through the bookmarked lines.

    I don’t know if this works well if there are already a smattering of bookmarks, and the newest text match can be anywhere in the file, i.e., OP wants to go to the specific text, which may not be the next bookmark…

    Or, even without Bookmark Line, after doing a normal Mark, you can use F3 (Search > Find Next) to navigate to the next match.

    Ah, yes, THAT may be the solution!