• 0 Votes
    4 Posts
    395 Views
    tseGITT

    thx to all, that works fine for me

  • Extract specific data from log files?

    10
    0 Votes
    10 Posts
    2k Views
    guy038G

    Hello, @zorba-greek, @michael-vincent, @terry-r and All,

    A one way solution would be to use the following regex S/R :

    SEARCH (?xs-i) ^ .+? Fleet \x20 No , ( \d+ ) , .+? tag= ( \d+) .+? $ | ^ .+

    REPLACE (?1Fleet No \: $1 tag \: $2:)

    This regex :

    Searches for two consecutive lines, without the ending line-break, containing the string Fleet No, with this exact case, in the first line and the string tag=, with this exact case, in the second one and replace these two lines with the string Fleet No : $1 tag : $2, where $1 and $2 are the numbers located after Fleet No and tag=

    When no more line contains the string Fleet No, it graps all the remaining text till the very end of the file and deletes it

    So for instance, I will try to describe the process with this dummy example below :

    FIRST alternative : (?xs-i) ^ .+? Fleet \x20 No , ( \d+ ) , .+? tag= ( \d+) .+? $ [22-12-20 21:18:44.345] FROM LIVE <02:PAYDONE=0000022852>CRLF <---------------------------------------------------------------- ^ .+? [22-12-20 21:19:16.399] FROM LIVE <03:PAYDONE=0000022853>CRLF ----------------------------------------------------------------- .+? [22-12-20 21:21:54.286] FROM LIVE <$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1>CRLF -------------------------------------------------------------------------------->Fleet No,<--><-------------------------------- .+? Fleet No, \d+ .+? Fleet No, $1 [22-12-20 21:21:54.301] auth accepted tag=9812120450668854 device=V2CRLF --------------------------------------->tag=<--------------><--------> ( line-break NOT included in the regex ) .+? tag= ( \d+ ) .+? $ tag= $2 SECOND alternative : ^ .+ [22-12-20 21:25:11.284] FROM LIVE <02:PAYDONE=0000022854>CRLF ----------------------------------------------------------------- ^ .+ [22-12-20 21:25:20.141] FROM LIVE <04:PAYDONE=0000022855>CRLF ----------------------------------------------------------------- ( End of file ) .+

    Now, given the exact INPUT text, provided by @zorba-greek :

    [22-12-20 21:16:04.521] FROM LIVE <$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5411,34319,TARJETA,,51.75,,3,0,1> [22-12-20 21:16:04.553] auth accepted tag=9812120450668474 device=V2 [22-12-20 21:16:40.185] FROM LIVE <02:PAYDONE=0000022851> [22-12-20 21:17:20.677] TO LIVE <$011B4910:FleetCard_1:9812120450669349> [22-12-20 21:17:21.270] FROM LIVE <$011B4910:FleetCard_10:1,49.48,1,1,200001,Fleet No,5237,34320,TARJETA,,49.48,,2,0,1> [22-12-20 21:17:21.333] auth accepted tag=9812120450669349 device=V1 [22-12-20 21:18:44.345] FROM LIVE <02:PAYDONE=0000022852> [22-12-20 21:19:16.399] FROM LIVE <03:PAYDONE=0000022853> [22-12-20 21:20:18.292] TO LIVE <$011B5150:FleetCard_1:9812120450669482> [22-12-20 21:20:19.073] FROM LIVE <$011B5150:FleetCard_10:1,51.75,1,1,200001,Fleet No,2001,34321,TARJETA,,51.75,,3,0,1> [22-12-20 21:20:19.167] auth accepted tag=9812120450669482 device=V1 [22-12-20 21:21:53.536] TO LIVE <$011B4B50:FleetCard_1:9812120450668854> [22-12-20 21:21:54.286] FROM LIVE <$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1> [22-12-20 21:21:54.301] auth accepted tag=9812120450668854 device=V2 [22-12-20 21:25:11.284] FROM LIVE <02:PAYDONE=0000022854> [22-12-20 21:25:20.141] FROM LIVE <04:PAYDONE=0000022855>

    We get the expected OUTPUT text :

    Fleet No : 5411 tag : 9812120450668474 Fleet No : 5237 tag : 9812120450669349 Fleet No : 2001 tag : 9812120450669482 Fleet No : 5418 tag : 9812120450668854

    Notes :

    In the search regex, I use the free-spacing mode, (?x), for an easy reading of the different parts of this regex

    You probably noticed that all ranges of text, in my regex, need to be non-greedy ranges ( Syntax = .+? ), as each range must not contain, itself, the strings Fleet No and tag= nor the final line break !

    As this regex does not include the final line-break, it will keep them, as is, in the OUTPUT text

    The replacement regex (?1Fleet No \: $1 tag \: $2:) means :

    IF a Fleet number is found ( (?1... ) it rewrites the string Fleet No : followed with the Fleet number ( $1 ), the string tag = and the tag number $2, all separated with space chars and colon chars when needed

    ELSE it replaces with everything between the last : character, after $2 and the end of the conditional replacement ) i.e. nothing so it deletes all the remaining text till the very end of current file !

    Remark that the two first : chars, in replacement, are literal characters and must be escaped, in order to be rewritten as is when the group 1 is present

    Best Regards,

    guy038

  • is there a way to move files up and down inside a list of opened files

    8
    0 Votes
    8 Posts
    2k Views
    ImbalanceI

    @mkupper Thanks, I was just looking a way to move items up and down in the “Document list” pane, and that’s exactly the way (Ctrl-Shift-PageUp and Ctrl-Shift-PageDown). Awesome.

  • Can I tell np++ the encoding via pseudo comment?

    10
    0 Votes
    10 Posts
    1k Views
    Alan KilbornA

    Just to circle back (finally) on this; I ended up NOT pursuing a scripted solution to this because I didn’t hear anything back from the OP, and I don’t have great interest in this for my own use. Just FYI.

  • Find/replace across 100's of servers using automated script

    7
    0 Votes
    7 Posts
    487 Views
    Michael VincentM

    @Steve-Mueller

    So you need a local scripting / templating solution that allows you to specify the INI file template and variables and then have a “database” of variable to value mappings for each server. Run a script to create the configs, Ansible to deploy.

    There are several templating frameworks out there (Jinja2 and Mako come to mind for Python).

    I’m still failing to see how any of this is related to Notepad++ other than using Notepad++ to edit the files / templates and write your scripts.

    Cheers.

  • Find and delete <p></p>line in HTML

    6
    0 Votes
    6 Posts
    2k Views
    Alan KilbornA

    @jackdeland said in Find and delete <p></p>line in HTML:

    Do you really want approx. 60 permutations and slapdash tries at everything? I am working 4 deadlines currently and don’t have anymore time to learn all I need. I have only twice asked for help in a forum with others far beyond my tech proficiency in one area, and I see I am dealing with some very insecure people. SO glad I am not in your world.

    Wow. Seriously.

    Since the answer was provided before that rant was typed, paraphrasing it, I think it reads “Thank you Peter Jones for the kindly help”.

  • Search In Files does not work for PDF

    3
    0 Votes
    3 Posts
    2k Views
    PeterJonesP

    @SAMEER-NAVARE ,

    See the FAQ for more on what Alan mentioned.

  • No smaller Line Spacing

    2
    0 Votes
    2 Posts
    1k Views
    PeterJonesP

    @GregorJan ,

    For font size, it is absolutely possible. Here are a pair of screenshots showing that I have Default Style at 10pt and Line Number Margin at 5pt:
    3005c100-1f3a-43c3-a01f-9a7d6e2e9e0f-image.png
    5ff071c8-e49d-4045-8640-5ab9e07d2bad-image.png

    Or here’s one with Brace Highlight Style set to 5pt – the first screenshot shows the braces not highlighted, at 10 pt; the second shows them highlighted, at 5pt.
    f5903d88-cbfe-4499-9fc1-8861c82d7779-image.png
    a2628fe2-f039-42e8-bb35-e4e214adb8f3-image.png

    However, you said,

    line spacing

    Sorry, line spacing is not individually configurable. Notepad++ computes the smallest line spacing it can from all the applicable font-size settings.

    The reason it cannot follow just the line number or brace-matching height is because a line can be a mix of various styles:
    b0c86279-d5c6-4983-b610-745c7b7f0e8f-image.png

    In the ExtSettings plugin, you can use negative values (you have to use the down arrows to go negative; it wouldn’t let me type a negative value) in the line-spacing entries, which allows you to “squish” the line size lower than Notepad++ wants to go; that might be sufficient for you:
    728295fd-5b57-4ab4-bad9-660e31d5758a-image.png

    Warning: If you go too negative, it will clip normal text:
    1fe90f25-230f-44eb-acb3-2781702d2403-image.png

  • File Cannot Be Saved

    8
    0 Votes
    8 Posts
    2k Views
    datatraveller1D

    @PeterJones You are absolutely right about the administrator mode. I used to find administrator mode somehow better, but it is not:

    e.g. drag and drop from MS Windows Explorer can no longer be used when Notepad++ is open in administrator mode in Vista and later because low-privileged processes cannot send messages to higher-privileged processes,

  • Wildcard Find/Replace with numerous lines in between?

    2
    0 Votes
    2 Posts
    4k Views
    PeterJonesP

    @Michael-Beck said in Wildcard Find/Replace with numerous lines in between?:

    Anyone know if this is possible

    Yes, someone knows it is possible.

    Oh, you wanted more than that, eh? ;-)

    Then yes, I know it is possible.

    Still not enough? ;-)

    Use the “Regular Expression” mode an “☑ . matches newline” checkbox.

    Specifically:

    FIND = "items": \\[.*?\\]
    REPLACE = "items": []

    2a11071a-2b50-41bb-932b-7cfe502b39d5-image.png

    You need to use \\[ instead of just [ in the FIND expression, because [ has special meaning to regex, and the \ prefix tells the regex to look for the literal opening square bracket, not treat it as the special regex character

    ----

    Useful References Please Read Before Posting Template for Search/Replace Questions Formatting Forum Posts Notepad++ Online User Manual: Searching/Regex FAQ: Where to find other regular expressions (regex) documentation
  • Encoding of files with ASCII only

    4
    0 Votes
    4 Posts
    5k Views
    EkopalypseE

    @rdipardo

    If I understood the question correctly, OP implicitly asked if there is a way to report the encoded file as, in his case, ANSI if it contains only ASCII characters. Based on my previous statement, this is not possible. Even if I use a hex editor, there is no way to tell if I wanted to use the file as ANSI or as some other encoding with ASCII characters as a subset. If I misunderstood the question, sorry.

  • copy all mobile numbers starting with 9

    4
    0 Votes
    4 Posts
    973 Views
    Paul WormerP

    @guy038 Thank you. I always overlooked the button Copy Marked Text. Now I understand that it copies to the clipboard, good to know!

  • 0 Votes
    7 Posts
    405 Views
    guy038G

    Hello, @datatraveller1 and All,

    No, I think that your regex S/R is just the right one and cannot be improved significantly ;-))

    Perhaps it’s good to recall that, at the end of your replacement string, you must insert \r\n if you use Windows files OR \n if you use Unix files

    An other formulation would be to split out this S/R in two individual S/Rs :

    SEARCH [([0-9])],?

    REPLACE $1\)\);\r\n

    Then :

    SEARCH (?-s)^(?=.)

    REPLACE System.out.println\(dataStream.consec\

    But, no advantage for doing this as the first search regex is identical in the two cases !

    Best Regards,

    guy038

  • Filter data

    9
    0 Votes
    9 Posts
    1k Views
    datatraveller1D

    @Alan-Kilborn Great, Thank you!

  • find missing closing brackets

    2
    0 Votes
    2 Posts
    2k Views
    PeterJonesP

    @Mary-Cook ,

    It would be the same, except use \\[ or \x5B instead of the first quote (for the part where you want to match the opening bracket). And \\] or \x5D instead of the closing quote (to match the closing bracket).

    Or if you mean () for brackets, then use \( or \x28 for the opening parentheses, and \) or \x29 for the closing parentheses.

    Or if you mean {} for brackets, then use { or \x7B for the opening curly brace, and } or \x7D for the closing curly brace.

    User Manual: Regular Expressions
  • Delete spaces not followed by characters

    5
    0 Votes
    5 Posts
    901 Views
    G

    @Alan-Kilborn

    This one works perfectly

    Thanks again for your help !!

  • More space at the left of the first column

    13
    0 Votes
    13 Posts
    1k Views
    Alan KilbornA

    @guy038 said in More space at the left of the first column:

    And to get the very end of current line, in all cases, affect a shortcut to the Scintilla command SCI_LINEEND

    That reminds me of some related discussion as part of this thread: https://community.notepad-plus-plus.org/topic/23381

  • How do I move bookmarks to a copy of the same file?

    20
    0 Votes
    20 Posts
    3k Views
    Paul WormerP

    @Paul-Wormer
    I prepared a pedestrian script that mimicks the all command of Xedit and Kedit. Just like those two editors (that both date from before color screens came into existence) my script doesn’t do any coloring. I hope that the bug in the Scintilla routine hideLines is circumvented by invoking it twice. [During my writing of the script, it indeed happened several times that not all lines were hidden after issuing editor.hideLines(0, int(editor.getLineCount())-1 )].

    Here comes the script:

    # -*- coding: utf-8 -*- from __future__ import print_function # Python 2.7 from Npp import * def disp_only_lines(string_to_show): ''' Display only the lines that contain `string_to_show`. ''' Lines_to_show = set() def handle(m): Lines_to_show.add(editor.lineFromPosition(m.start())) # Loop over whole file, calling `handle` for each find: editor.search(string_to_show, handle) # Sort numbers of lines containing `string_to_show`: Lines_to_show_sorted = sorted(list(Lines_to_show)) # Hide all lines (twice because of bug in Scintilla): editor.hideLines(0, int(editor.getLineCount())-1 ) editor.hideLines(0, int(editor.getLineCount())-1 ) # Actual showing of lines to be shown: for line_shown in Lines_to_show_sorted: editor.showLines(line_shown, line_shown) def tab_callback(args): ''' Called after return from other tab. ''' global save_bufferID, display_all, string_to_show if save_bufferID == args['bufferID'] and not display_all: disp_only_lines(string_to_show) #### Main #### save_bufferID = notepad.getCurrentBufferID() notepad.clearCallbacks(tab_callback) notepad.callback(tab_callback, [NOTIFICATION.BUFFERACTIVATED]) # Role of boolean `display_all`: # if true all lines are displayed, else some lines are hidden. try: if display_all: string_to_show = editor.getSelText() editor.setEmptySelection(editor.getCurrentPos()) # Undo selection except NameError: # First time in, `display_all` does not exist display_all = True string_to_show = editor.getSelText() editor.setEmptySelection(editor.getCurrentPos()) # Undo selection if len(string_to_show) == 0 and display_all: notepad.messageBox('No string selected', 'all.py') else: if display_all: disp_only_lines(string_to_show) display_all = False # Not all lines are displayed else: editor.showLines(0, int(editor.getLineCount())-1 ) display_all = True # All lines are displayed string_to_show = ''
  • replacing a specific text from a another file

    14
    0 Votes
    14 Posts
    5k Views
    fenzek1F

    Thank you guys.
    For your feedback to me.
    I will study the subject of “regular expressions” in more detail.

    If it applies to my work and makes it VERY easy, then I must know something about it right.

    I’ve looked at your answers before, and they’ve helped me with other obvious things, but obviously I didn’t understand anything about coding,
    Still, your altruism and help made sense to me.
    And the way you help people is nothing but respect.
    Thank you from the bottom of my heart.

    I understand that old-timers are willing to give a year, a couple of years, or even a decade to learn.
    And then someone like me shows up and “help me do it for me,” no, that’s not it, and that’s not the plan I had when I started my thread.

    You showed me, and for that I want to say thank you.

  • Fold/Unfold is acting inconsistently.

    3
    1 Votes
    3 Posts
    343 Views
    ludamo 0L

    Yes I noticed something like this recently. I folded a few functions in a large AHK file (over 3000 lines), then started to add a new function below the folded ones and seemed to lose the folded functions? Fortunately multiple undoes saved me from starting from a backup.
    I tried it again just now but couldn’t replicate it. I am using version 8.4.8.