• Developing generic regex sequences

    22
    3 Votes
    22 Posts
    12k Views
    Lycan ThropeL

    @alan-kilborn ,
    It actually let’s you use different regex flavors, (PCRE pre 7.3 and 7.3 plus, ECMAScript, Python, Golang, Java8, and .NET(C#), but the benefit of regex101.com, is that you can interactively see how your regex construction is going to work on the text you supply, either just Search or both Search and Replace. It’s actually educational to see what happens as you experiment with different regex constructions. You have to construct and then execute NPP to see results, and you’re not sure what you did wrong unless there’s a mode in NPP that does the same interactive result. I use it all the time to construct the regex I’ve been building, to be able to quickly see how the regex I’m constructing works on their supplied text. It’s just another tool, and it is recommended as Peter points out in the FAQ, which is where I learned about it. So I can see why someone might want to use that tool, Alan. :)

  • Comparing issue

    2
    0 Votes
    2 Posts
    801 Views
    PeterJonesP

    @manish-thukral ,

    You need to make sure you have the right version of the Compare plugin for your version of Notepad++. Check the Plugins Admin for updates on the plugin. (Specifically, if you are at NPP v8.3 or newer, you must use Compare Plugin 2.0.2 or it will not work right.)

  • tài liệu quản lý dự án.

    2
    0 Votes
    2 Posts
    732 Views
    PeterJonesP

    When Google Translate changes your post to English:

    There are two project management models, waterfall and agile

    This doesn’t seem to have anything to do with Notepad++. Please keep posts in the Notepad++ Community related to Notepad++.

  • Generic Regex: Replacing in a specific zone of text

    2
    6 Votes
    2 Posts
    3k Views
    guy038G

    Two other examples regarding this generic regex ! In these ones, we’ll even restrict the replacements to each concerned zone before a # character !

    Paste the text below in a new tab :

    <iden>123456 (START)</iden> <name>Case_1</name> <descrip>This is a (short) text to (easily) see the results (of the modifications)# (12345) test (67890)</descrip> <param>val (250)</param> <iden>123456</iden> <name>Case_2</name> <descrip>And the (obvious) changes occur only in (the) "descrip" tag # Parentheses (Yeaah) OK</descrip> <param>val (500)</param> <iden>123456 (END)</iden> <name>Case_3</name> <descrip>All (the) other tags are (just) untouched #(This is) the end (of the test)</descrip> <param>val (999)</param>

    In this first example, of single-line <descrip> tags , two solutions are possible :

    Use the complete generic regex (?-si:BSR|(?!\A)\G)(?s-i:(?!ESR).)*?\K(?-si:FR) where ESR = # which leads to the functional S/R :

    SEARCH (?-s)(?-i:<descrip>|(?!\A)\G)((?!#).)*?\K(?:\x20\(.+?\))

    REPLACE Leave EMPTY

    => This time, in addition to only replace in each <descrip>..........</descrip> zone, NO replacement will occur after the # character of each <descrip> tag !

    Use the simplified solution and add a ESR condition at the end of the regex, giving this generic variant (?-s)(?-i:BSR|(?!\A)\G).*?\K(?-i:FR)(?=ESR)

    SEARCH (?-s)(?-i:<descrip>|(?!\A)\G).*?\K(?:\x20\(.+?\))(?=.*#)

    REPLACE Leave EMPTY

    However, this other solution needs that all the <descrip> tags contains a comment zone with a # char

    Now, paste this other text below in a new tab :

    <val>37--001</val> <text>This-is -a--very---< # Dashes - - - OK/text> <pos>4-1234</pos> <val>37--002</val> <text>-small----#---example</text> <pos>9-0012</pos> <val>37--003</val> <text>-of-a-text- which-</text> <pos>1-9999</pos> <val>37--004</val> <text>need -to-be- modi fied # but - not - there</text> <pos>0-0000</pos>

    This second example is a multi-lines replacement, in each <text>.............</text> zone only and also limited to the part before a # char which can be present or not

    Of course, we’ll have to use the complete generic regex (?-si:BSR|(?!\A)\G)(?s-i:(?!ESR).)*?\K(?-si:FR) but, instead of a single (?!ESR), we’ll have to use this variant :

    (?-si:BSR|(?!\A)\G)(?s-i:(?!ESR_1)(?!ESR_2).)*?\K(?-si:FR)

    So, the functional regex S/R becomes :

    SEARCH (?-si:<text>|(?!\A)\G)(?s-i:(?!</text>)(?!#).)*?\K-+

    REPLACE \x20

    => ONLY IF a sequence of dashes is located in a <text>..........</text> zone AND, moreover, before a possible # char, it will be replaced with a single space character

    As you can verify, the third multi-lines <text>.............</text> zone does not contain any # char. Thus, all dash characters, of that <Text> tag, are replaced with a single space char !

    Remainder :

    You must use, at least, the v7.9.1 N++ release, so that the \A assertion is correctly handled

    Move to the very beginning of file, before any Find Next sequence or Replace All operation

    Do not click on the step-by-step Replace button

  • 1 Votes
    1 Posts
    727 Views
    No one has replied
  • Generic Regex: Logic Gates for Regular Expressions

    2
    2 Votes
    2 Posts
    3k Views
    Lycan ThropeL

    @peterjones ,
    Thank you for this synopsis. This will take a little while to digest, but at least there is a succinct description we neophytes can come and learn the way you explain things in detail. Thanks again.

  • Crash and Loose

    3
    0 Votes
    3 Posts
    897 Views
    PeterJonesP

    @cinetica-constructiva ,

    Since you claim you have Notepad++ v8.2 (showing us ?-menu’s Debug Info would give us more to go on), then I can ask: Did you leave the nppLogNulContentCorruptionIssue.xml in the Notepad++ installation folder? If so, did Notepad++ create nppLogNulContentCorruptionIssue.log, either in %AppData%\Notepad++ (or the Notepad++-in-Wine-in-Ubuntu equivalent) or in the Notepad++ installation folder. Despite using it in an unsupported environment, that logfile may contain useful information.

  • PasteSpecial - revisited

    16
    4 Votes
    16 Posts
    4k Views
    PeterJonesP
    pasteSpecial.pl - v2.1

    Updates:

    Fix “bitmap” bug (if a bitmap was in the clipboard, trying to preview would cause script to crash)

    Requirements:

    Perl Install “PerlScript” module

    Usage

    Notepad++ menu: Run > Run: "c:\path\to\perl.exe" "c:\path\to\pasteSpecial.pl" #!/usr/bin/env perl ################################################ # PasteSpecial for Notepad++ # List formats currently on the clipboard # Allows you to choose one of those formats # Will paste the selected type (UTF8-encoded) # at the current location in the active file ################################################ # HISTORY # v0.1: STDIN-based choice # v1.0: DialogBox choice # v2.0: Add REFRESH button to update the ListBox # Defaults to selecting/displaying the first Clipboard variant # Persist checkbox allows dialog to stay open for multiple pastes # v2.1: Fix the "bitmap" bug (having bitmaps is clipboard caused crash) ################################################ use 5.010; use warnings; use strict; use Win32::Clipboard; use Win32::GUI; use Win32::GUI::Constants qw/CW_USEDEFAULT/; use Encode; use Win32::Mechanize::NotepadPlusPlus 0.004 qw/:main/; # this works even with v0.004, even without bugfix for prompt() our $VERSION = 'v2.1'; BEGIN { binmode STDERR, ':utf8'; binmode STDOUT, ':utf8'; } my %map = ( CF_TEXT() => 'CF_TEXT', CF_BITMAP() => 'CF_BITMAP', CF_METAFILEPICT() => 'CF_METAFILEPICT', CF_SYLK() => 'CF_SYLK', CF_DIF() => 'CF_DIF', CF_TIFF() => 'CF_TIFF', CF_OEMTEXT() => 'CF_OEMTEXT', CF_DIB() => 'CF_DIB', CF_PALETTE() => 'CF_PALETTE', CF_PENDATA() => 'CF_PENDATA', CF_RIFF() => 'CF_RIFF', CF_WAVE() => 'CF_WAVE', CF_UNICODETEXT() => 'CF_UNICODETEXT', CF_ENHMETAFILE() => 'CF_ENHMETAFILE', CF_HDROP() => 'CF_HDROP', CF_LOCALE() => 'CF_LOCALE', ); my %rmap; @rmap{values %map} = keys %map; my $CLIP = Win32::Clipboard; my $answer = runDialog(); #editor->addText(Encode::encode("UTF8", $answer)) if defined $answer; #v1.3: moved to the PASTE button, below exit; sub formats { my @f = $CLIP->EnumFormats(); foreach my $format (sort {$a <=> $b} @f) { $map{$format} //= $CLIP->GetFormatName($format) // '<unknown>'; $rmap{ $map{$format} } = $format; } return @f; } sub runDialog { my $clipboard; my $persist = 1; my $dlg = Win32::GUI::Window->new( -title => sprintf('Notepad++ Paste Special %s', $VERSION), -left => CW_USEDEFAULT, -top => CW_USEDEFAULT, -size => [580,300], -resizable => 0, -maximizebox => 0, -hashelp => 0, -dialogui => 1, ); my $icon = Win32::GUI::Icon->new(100); # v1.1: change the icon $dlg->SetIcon($icon) if defined $icon; my $update_preview = sub { my $self = shift // return -1; my $value = $self->GetText($self->GetCurSel()); my $f=$rmap{$value}; $clipboard = $CLIP->IsBitmap() ? $CLIP->GetBitmap() : $CLIP->IsFiles() ? ($CLIP->GetFiles())[0] : $CLIP->GetAs($f); $clipboard = Encode::decode('UTF16-LE', $clipboard) if $f == CF_UNICODETEXT(); (my $preview = $clipboard) =~ s/([^\x20-\x7F\r\n])/sprintf '\x{%02X}', ord $1/ge; $preview =~ s/\R/\r\n/g; $preview = substr($preview,0,297)."..." if length($preview)>300; $self->GetParent()->PREVIEW->Text( $preview ); return 1; }; my $lb = $dlg->AddListbox( -name => 'LB', -pos => [10,10], -size => [230, $dlg->ScaleHeight()-10], -vscroll => 1, -onSelChange => $update_preview, # v1.2: externalize this callback so it can be run from elsewhere ); my $refresh_formats = sub { my $lb = $dlg->LB; my $selected_idx = $lb->GetCurSel() // 0; my $selected_txt = ((0<=$selected_idx) && ($selected_idx < $lb->Count)) ? $lb->GetText($selected_idx) : ''; $lb->RemoveItem(0) while $lb->Count; $lb->Add( @map{ sort {$a<=>$b} formats() } ); my $new_idx = $selected_txt ? $lb->FindStringExact($selected_txt) : undef; $new_idx = undef unless defined($new_idx) && (0 <= $new_idx) && ($new_idx < $lb->Count); $lb->Select( $new_idx//0 ); $update_preview->( $lb ); }; my $button_top = $dlg->LB->Top()+$dlg->LB->Height()-25; $dlg->AddButton( # v1.2: add this button -name => 'REFRESH', -text => 'Refresh', -size => [80,25], -left => $dlg->ScaleWidth()-90*3, -top => $button_top, -onClick => sub{ $refresh_formats->(); 1; }, ); $dlg->AddButton( -name => 'OK', -text => 'Paste', -size => [80,25], -left => $dlg->ScaleWidth()-90*2, -top => $button_top, -onClick => sub{ # v1.3: allow to persist after paste: TODO: move the editor->addText here editor->addText( Encode::encode("UTF8", $clipboard) ) if defined $clipboard; return $persist ? 1 : -1; }, ); $dlg->AddButton( -name => 'CANCEL', -text => 'Cancel', -size => [80,25], -left => $dlg->ScaleWidth()-90*1, -top => $button_top, -onClick => sub{ $clipboard=undef; -1; }, ); $dlg->AddGroupbox( -name => 'GB', -title => 'Preview', -pos => [250,10], -size => [$dlg->ScaleWidth()-260, $button_top-20], ); $dlg->AddLabel( -name => 'PREVIEW', -left => $dlg->GB->Left()+10, -top => $dlg->GB->Top()+20, -width => $dlg->GB->ScaleWidth()-20, -height => $dlg->GB->ScaleHeight()-40, ); $dlg->AddCheckbox( -name => 'CB', -text => 'Persist', -pos => [$dlg->GB->Left(), $button_top], -onClick => sub { $persist = !$persist; 1; }, ); $dlg->CB->SetCheck($persist); $refresh_formats->(); $dlg->Show(); Win32::GUI::Dialog(); return $clipboard; }
  • Marking/Searching/Replacing issues

    2
    0 Votes
    2 Posts
    667 Views
    Alan KilbornA

    @Paul-Whaley

    What does this part of the Find dialog look like for you?:

    c95f467e-7e0a-4aa1-8f6d-a352df8601d8-image.png

    Seems like you want Normal but you probably have Regular expression set ??

  • 1 Votes
    4 Posts
    2k Views
    marianogedismanM

    T-This is BEAUTIFUL ( ♡∀♡)

  • Youssef Land and Notepad++ Community

    2
    -1 Votes
    2 Posts
    653 Views
    Alan KilbornA

    @yoyomonem

    If that’s an announcement of a new OS from Microsoft, I think you missed the mark by almost a couple of decades. And it’s off-topic for a Notepad++ forum.

  • The snake game in python

    2
    0 Votes
    2 Posts
    1k Views
    Alan KilbornA

    One question: WHY?

  • Search issue

    2
    0 Votes
    2 Posts
    679 Views
    Alan KilbornA

    @A-Shrinivas-Rao said in Search issue:

    f I need to go up I need to check Backward direction or vice versa.

    Have you tried 2-button find mode?

    Turn it on with this, by ticking the box with the speech bubble:

    36cfa5b3-f961-4b4a-8186-c513923c9054-image.png

    And it will then look like this:

    6e20872c-60a3-4ca5-b349-49c31f09978f-image.png

    And you can then forget the Backward direction checkbox is even there.

    Alternatively, with the keyboard, Enter will search forwards and Shift+Enter will search backwards.

    Plenty of options so your time isn’t wasted. :-)

  • Help me Please.I don's solv this problem.

    6
    0 Votes
    6 Posts
    1k Views
    Md ZiarulM

    @Alan-Kilborn I use run in chrome.

  • Long paths support

    17
    0 Votes
    17 Posts
    6k Views
    Juan MillerJ

    Try “LongPathTool program” that is best solution.

  • Multiple Vertical Edges: Documentation

    1
    2 Votes
    1 Posts
    2k Views
    No one has replied
  • Launch in default Web browser

    3
    3 Votes
    3 Posts
    9k Views
    ?

    From my point of view, I was wondering how Search on Internet worked versus the Launch in Chrome, Launch in Firefox etc shown in the default shortcuts.xml. I had long copied the examples in shortcuts.xml for browser shortcuts. But, I was then forced to modify shortcuts.xml when I switched my default browser. Those examples always explicitly gave a browser (due to Web development). And I followed that convention. Search on Internet followed the default browser.

    I first tried searching in the NPP sources. But I can’t read C++ well enough.

    I happened on Launch in Web browser · Issue #472 where Mr. Ho simply says “It’s been done.” I wasn’t sure what that could mean and then found the answer I linked to in my original post.

    I typically disable clickable links as a first customization. So, it made sense to me that clickable links was the implied solution.

    My muscle memory is set to the shortcuts I’ve developed. So, I kept experimenting with the examples in shortcuts.xml until I realized <command /> was just some escaped wrapper for a plain Run prompt. I had previously made the leap to use Start-Process to invoke URLs from the shell. So, I tried directly invoking a URL from NPP and it worked.

    I did not realize there had been a recent discussion. My searches had centered around “default Web browser” thus the GitHub issue. I don’t remember seeing this other discussion.

    Now, even my PowerShell function has encoding and a fixed protocol. – Since this literally executes whatever is selected, I threw in annoying warnings.

  • Help add a feature to the site

    2
  • After updating plugins and theme my WordPress website is down

    2
  • Insist on a Roadmap to Start Development

    2
    0 Votes
    2 Posts
    764 Views
    Alan KilbornA

    @Javier-Sánchez

    See https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/CONTRIBUTING.md

    with the fact that the developers, apparently don’t take a glance here

    I’m sure some do and some don’t.

    I want to contribute with the syntax ruling and look of a very well known programming language (which I’d mention later on) in a very well known hardware (which I’d mention later). Why mention later? Well, when I get the least hint, I’ll do that.

    “which I’d mention later”? With a statement like that, I’m sure absolutely no one cares. Good luck with the results to your "insist"ing.