• Question about replacement

    6
    0 Votes
    6 Posts
    1k Views
    PeterJonesP

    @Acme1235 said in Question about replacement:

    So if I understand the code correctly, you captured the (<g) and then started scrolling through characters.

    technically, captured the <g, and characters necessary after that to make the whole match work

    \s denotes a new line.

    \s* denotes 0 or more of any whitespace (space, tab, newline)

    The * makes it look for the id=

    The * was the 0-or-more quantifier for the \s

    the id=" makes it look for id="

    And then the \d denotes a digit.

    Yep.

    Thanks again for the help! You’ve been a lifesaver.

  • Copy data found in one file to another/new file

    3
    1 Votes
    3 Posts
    948 Views
    guy038G

    Hello, @mike-gill,

    Yeah, that’s the right way ! However, Mike, note that, before the v7.9.1 release, where the Copy Marked Text button was added, we were forced to use a regex S/R to achieve the same goal !

    But this way still works nice with last releases ! For instance :

    Copy the contents of your .log file in a new tab

    Open the Replace dialog ( Ctrl + H )

    SEARCH (?s)^.+?(dstip=.+?)(?=\x20)|.+

    REPLACE \1\r\n

    Tick the Wrap around option

    Select the Regular expression search mode

    Click on the Replace All button

    Save these modified contents

    Et voilà !

    Best Regards,

    guy038

  • Change a line..

    12
    0 Votes
    12 Posts
    344 Views
    Carolina Number 1C

    @PeterJones said in Change a line..:

    = ${1}“${2}”;

    This worked like a charm:

    (?-is)^(title = )(.*?); Variation name"
    ${1}${2};"

    I think I can adapt it or tweak it if I need too.

    Thanks @PeterJones @Alan-Kilborn

  • Commandline Parameter -l <vb> or -l vb does not set the Language to VB

    3
    0 Votes
    3 Posts
    254 Views
    Thomas HabermannT

    @Alan-Kilborn
    Thanks for your msg! I can see the selected file correctly but just in “Normal” if I swith the Langage manually it works correctly as it should! Only the command line Parameter had no effect - I tried also -lvb earlier in the 64Bit version
    How ever, using -lvb works correctly now in the 32Bit version
    -SOLVED

  • 1 Votes
    8 Posts
    989 Views
    Alan KilbornA

    @ginger-manson said in How to move numbers at end of line to new position in same line farther to the right I normally tab them over to:

    @guy038 I really liked the look of what you accomplished with your method, but honestly I got lost trying to implement it.

    This can be a problem sometimes with the solutions Guy offers, but hmm, in this case I just followed the steps and it worked exactly right, so I encourage the OP to try it again.

  • Identical strings in column

    26
    0 Votes
    26 Posts
    2k Views
    Petr JajaP

    @PeterJones , @guy038

    I have tested your solutions and both work fine. However, for futher work I will use probably the solution from @guy038 because it is a little bit faster.
    Thank you very very much for your help.

    Tested - NP v.7.9.3 on Win10, Win7

  • Prb multiple words in the sentence

    6
    0 Votes
    6 Posts
    339 Views
    Terry RT

    @Mamoune-Zerhouni-faiz said in Prb multiple words in the sentence:

    Sorry to have exaggerated but please I don’t understand anything about Notepad++ commands
    I just discovered another error ‘double repeated words’ in sentences, such as:

    Well, possibly you need to start learning about regular expressions as we cannot continue to give you the answer every time without you at least trying first. In our FAQ section we have a post on REGEX (regular expressions). Try to learn some of the basics which is the best starting point. If you do try, but fail, show us what you have attempted. You will get more offers of help if you at least try.

    Your latest problem with “double repeated words” was actually more complex than I initially thought hence the time taken to get back to you with a possible solution. Again it is a regular expression so search mode MUST be “regular expression”. Using the Replace function we have:
    Find What:\b(\w+)(?=\W(\w+)\W\1\W\2)(\W)(\w+)\W\1\W\2
    Replace With:\1\3\4

    To give a bit of a description:
    We look for an entire word (\b before the \w+ forces that). At this point we look ahead (?= is a lookahead, this does not actually consume any characters). The lookahead looks for a non word character (\W which can be a space, comma etc) a 2nd word, then another non-word character and the 1st word again followed by a non-word character and the 2nd word. If none of this is true, then the regex fails with the first word and proceeds to the next word, consuming it and repeats the lookahead. Once the lookahead is true then we proceed with actually consuming the 2nd word and the duplicates. In this instance I only look for 1 duplicate as that’s what your example suggests. If more than 1 duplicate exists, then run the regex again until no more duplicates exist.

    Terry

    PS when we ask that examples be entered using the </> button please follow that request. It is important you supply both before and after views of the data in the black boxes so that we know the data can be trusted as correct and not altered by the posting engine. In this case the example you supplied might not have been affected but that’s not always the case.

  • Operators 2 (seperators required) not working?

    2
    0 Votes
    2 Posts
    329 Views
    PeterJonesP

    @David-Abrahams-0 ,

    2236f51b-12c2-4430-b532-870679151c7a-image.png

    It works as expected for me.

    Could you show your UDL (if there isn’t proprietary/private/sensitive information contained in the definition)? (You could even Export… the UDL, and then paste the contents of that exported XML file into your reply)

    Also, it’s always good to post the ? menu’s Debug Info (copy/paste) when asking for help that might end up being version-dependent.

  • How do I merge two or more consecutive lines into one?

    26
    0 Votes
    26 Posts
    24k Views
    glossarG

    @guy038 said in [How do I merge two or more consecutive lines into one?]

    If you prefer, you may send it to me, by e-mail. Here is my temporary e-mail address :

    BR

    guy038

    Just sent it to the above address.

    Thank you!

  • Remove some mistakes !! Need help plz !

    3
    0 Votes
    3 Posts
    163 Views
    El kohen AmalE

    Thank you very much! It works!

    Merci encore :)

  • Where is 'Show vertical edge' setting in 7.9.3

    3
    0 Votes
    3 Posts
    201 Views
    Alex CA

    @Alan-Kilborn thank you, good sir, your belief really helped me!
    Now it’s in Preferences > Margins/Border/Edge > Vertical Edge Settings

  • Add a new name before and after names that start with a capital letter

    12
    0 Votes
    12 Posts
    782 Views
    Alan KilbornA

    @PeterJones said in Add a new name before and after names that start with a capital letter:

    use (?-is) at the beginning

    My rule of thumb is becoming to type that, first thing after calling up the Find window, when I know I’m doing regex.

    I can always modify it later, but it is a good starting point.
    The discussion in this thread about case bears that out.

  • how do you hit preview in notepad++?

    2
    0 Votes
    2 Posts
    490 Views
    Alan KilbornA

    @Maria-Urbina

    A bit of a leap here, in understanding your question, but I’m guessing maybe you want to see what you’ve composed in a browser window?

    If so, have a look at the View menu, specifically the View Current File in menu item.

  • Ignore some text in regex

    2
    1 Votes
    2 Posts
    1k Views
    PeterJonesP

    @0YouKnow0 ,

    It’s great that you have a starting regex that works for the simple use case; thanks for sharing it, as it will make moving you forward to the end goal much easier.

    Recently, our super regex guru @guy038 published a post that gives a “generic” regex for searching and replacing for a particular expression, between START and END tags.

    Your search expression would be the FR in the generic, and your replacement expression would be the RR. Depending on how specific you want your START and END to be, I would probably pick a BSR = > and ESR = </, so that it will look for anything that matches your FR that’s between a > at the end of a tag and an </ at the beginning of the end tag. The generic expression was designed to disallow having the BSR or ESR inside the matched, so I believe that will do it for you. But if you only want it between certain tags, like only inside of <Data...>...</Data>, then you could make more detailed BSR and ESR.

    Actually, when I tried plugging those in as specified with the simpler BSR and ESR, I found that it didn’t quite match correctly:

    <Cell ss:StyleID="sReadWrite"><Data ss:Type="String">its just a normal line that i want to use above regex on it</Data></Cell> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ starts at <Data instead of at its

    You could limit that by not allowing your FR to match any > characters… so instead of (?-s).{65,80}, maybe [^>\r\n]{65,80}. No, that doesn’t solve it. :-(

    Wait, your expression only allows 65-80 characters before the space. But your text its just a normal line that i want to use above regex on it is only 59 characters long, so it’s not long enough to match. If I change the data contents to its just a normal line that i want to use above regex on it which has at least 65 characters in it, then your .-based still gets it wrong, but my modified character-class based FR will match:

    <Cell ss:StyleID="sReadWrite"><Data ss:Type="String">its just a normal line that i want to use above regex on it which has at least 65 characters in it</Data></Cell> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Even if I change to BSR = <Data.*?> and ESR = </Data>, it will incorrectly match with your (?-s).{65,80}(?=\x20), whereas FR = [^>\r\n]{65,80}(?=\x20) will grab just the first 65-80 characters before a space.

    Sometimes, even with the generic expressions, you have to do more exploring to get it to work.

    Hopefully, you can plug in the modified FR, and your choice of appropriate BSR and ESR, into the generic expression, and see how it works. And using the Find to show the various matches will help you debug issues before you go ahead and Replace. But, if you need help.

    ----

    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.

  • Finding characters and using them to replace

    3
    0 Votes
    3 Posts
    207 Views
    A

    @PeterJones thanks so much for the help and links! I’ll be using it a good bit in the upcoming weeks so I’ll definitely read up on it!

    Happy friday!

  • Hexadecimal Line numbers

    3
    1 Votes
    3 Posts
    3k Views
    Buz WilliamsB

    @PeterJones Thank you very much. Super simple, once you know where to look!! ;-)

  • Open files

    2
    0 Votes
    2 Posts
    133 Views
    PeterJonesP

    @Giovanni-Russo ,

    There is no way to change the default “filetype” in the Open dialog. If you want to filter by a certain filetype, then you just have to select the “filetype” yourself each time – or type the *.py in the “file name” box, which will also apply the filter.

    (On the Save As dialog, it is different, because there’s a setting which will determine whether a normal text file defaults to saving as *.* or *.txt … but that’s only for the Save/SaveAs dialog, not on the Open dialog.)

  • 0 Votes
    4 Posts
    1k Views
    Anandkumar PrajapatiA

    Hello,
    You can replace strings of text while retaining numbers in the middle of the line using RegEx.
    Follow the steps:
    Open your document in N++.
    Go to the start of the document by clicking on ctrl+home.
    Open The Replace Dialogue Box (ctrl+h).
    Under search, mode Select regular expression.
    write the following in the fields.
    Find what: (?i)(?s)owns = (\d{1,4})
    Replace with: $1 = { country_or_non_sovereign_subject_holds = ROOT }
    Click on Replace All.

    Description:
    (?s) enables dot matching newlines.
    (?i) makes match case insensitive.
    (owns) represents a literal string.
    (\d) (digit) matches any single digit (same as [0-9] ).
    {1,4} matches with a 1 to 4 digit number.
    $1 refers to the first match (in this case $1 will refer to the number i.e. 116).

  • regex: Parsing html tags in other tags / links and titles

    32
    -1 Votes
    32 Posts
    1k Views
    Robin CruiseR

    of course there are others, but only @guy038 helped me and all notepad++ community with so hard to find solutions.

    and I am using notepad++ and grepWin (and as for the Batch Process I using a great tool named TextCrawler)

  • Same number of characters for print & screen

    8
    1 Votes
    8 Posts
    361 Views
    PeterJonesP

    @carypt ,

    doesnt in printsettings of npp the wysiwyg (what you see is what you get) affect the look of the print

    Sorry, it affects the look of the print, but not the font size of the print.

    3b393041-6647-40bf-9e06-37760483f2b6-image.png

    Your suggestion of “wysiwyg” shows that you might not understand that option: as the “Colour Options” label on the box of options of which “WYSIWYG” is a part, those options affect the color of the print, not the font size or anything else. (Those options are all clearly documented in the Preferences > Print section of the online user manual)