• Wild card again

    Locked
    3
    0 Votes
    3 Posts
    2k Views
    Mark RomerM

    If you just want the file names, you can use a Regular expression find and replace. I’m not a regex expert, but this worked for me:

    Under Find what: ^.*\\(.+) n:.*$ Under Replace with: $1

    What this does is it matches an entire line (^ means the start of the line and $ means the end of the line). Within that line, it creates a capture group (the bit in parentheses, .+, which is one or more of any character) that is preceded by the part from the beginning of the line to a slash, and followed by a space followed by “n:” followed by zero or more characters to the end of the line. The $1 in Replace with means to replace with the contents of the first capture group.

    This will take you from

    copy k:\apps\demex\system\ABBREV.DBF n:\apps\demex\system\ABBREV.DBF /Y copy k:\apps\demex\system\TEST.DBF n:\apps\demex\system\TEST.DBF /Y copy k:\apps\demex\system\"abc def ghi.DBF" n:\apps\demex\system\"abc def ghi.DBF" /Y copy k:\apps\demex\system\1234567890.DBF n:\apps\demex\system\1234567890.DBF /Y copy k:\apps\demex\system\Me.DBF n:\apps\demex\system\Me.DBF /Y

    to

    ABBREV.DBF TEST.DBF "abc def ghi.DBF" 1234567890.DBF Me.DBF
  • UDL: Colon(:) at end of line as a keyword to style the whole line

    Locked
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Prefixes for numbers don't work with letters, when using own syntax

    4
    0 Votes
    4 Posts
    3k Views
    Сергей Чепцов68С

    @PeterCJ-AtWork Thanks a lot! It works - prefix 2 and extras 1. Really confusing…

  • Clean a file using Regex

    Locked
    3
    0 Votes
    3 Posts
    2k Views
    guy038G

    Hi all,

    In my previous post, I gave a general method to replace a specific character by an other, everywhere in lines of a delimited text, except for a range, between column c1 and c2. I now give you an extension of that method to SEVERAL fixed zones to exclude !

    I mean :

    ^---------- Zone 1 to exclude ------------ Zone 2 to exclude -------------------- Zone 3 to exclude ------------$

    So, let’s suppose the original text, below :

    abcd,04,,11111111, 22,ANYWORD ,ANYWORD,ANY,QZERTY,001,,5555,,AN,Y ANY,pqrst,00x,ANYWORD ,ANYWORD,9A9 ,Last Field, fghi,02,,22222222, 22,ANY ,ANY, WORDS, ANY,AZERTY,999,,6666,,ANY AN,Y,uvwxy,01y,ANY ,ANY, WORDS,,7Z3 ,Last Field, klmn,09,,33333333, 22,WORDS,ANY, WORDS,ANY,TEST-1,123,,7777,,ANY,,ANY,zabcd,02z,,ORDS,ANY, WORDS,3H5 ,Last Field,

    I defined 3 zones to exclude, where the comma character will NOT be changed, while the S/R process :

    The zone 1, which starts at column 26 and ends at column 52 => S1= 26 and E1 = 52 The zone 2, which starts at column 65 and ends at column 72 => S2= 65 and E2 = 72 The zone 3, which starts at column 84 and ends at column 99 => S3= 84 and E3 = 99

    As previously explained, we, temporarily, add the # or @ boundaries, in order to delimit these 3 zones, with the general S/R, below :

    ^(.{S1-1})(.{E1-S1+1})(.{S2-E1-1})(.{E2-S2+1})(.{S3-E2-1))(.{E3-S3+1})..............(.{Sn-En-1-1})(.{En-Sn+1})

    With the given values of S1 through E3 above, we get the following S/R :

    SEARCH : ^(.{25})(.{27})(.{12})(.{8})(.{11})(.{16})

    REPLACE : \1#\2@\3#\4@\5#\6@

    which gives us the delimited text, below, with the boundaries :

    abcd,04,,11111111, 22,#ANYWORD ,ANYWORD,ANY,QZERTY@,001,,5555,,#AN,Y ANY@,pqrst,00x,#ANYWORD ,ANYWORD@,9A9 ,Last Field, fghi,02,,22222222, 22,#ANY ,ANY, WORDS, ANY,AZERTY@,999,,6666,,#ANY AN,Y@,uvwxy,01y,#ANY ,ANY, WORDS,@,7Z3 ,Last Field, klmn,09,,33333333, 22,#WORDS,ANY, WORDS,ANY,TEST-1@,123,,7777,,#ANY,,ANY@,zabcd,02z,#,ORDS,ANY, WORDS@,3H5 ,Last Field,

    Then, running the second regex S/R, below :

    SEARCH : ,(?=[^@]*#)|,(?![^#]*@)|(#|@)

    REPLACE : (?1:_)

    we obtain the final text :

    abcd_04__11111111_ 22_ANYWORD ,ANYWORD,ANY,QZERTY_001__5555__AN,Y ANY_pqrst_00x_ANYWORD ,ANYWORD_9A9 _Last Field_ fghi_02__22222222_ 22_ANY ,ANY, WORDS, ANY,AZERTY_999__6666__ANY AN,Y_uvwxy_01y_ANY ,ANY, WORDS,_7Z3 _Last Field_ klmn_09__33333333_ 22_WORDS,ANY, WORDS,ANY,TEST-1_123__7777__ANY,,ANY_zabcd_02z_,ORDS,ANY, WORDS_3H5 _Last Field_

    As expected, all the commas, located from column 26 till column 52, from column 65 till column 72 and from column 84 till column 99, have NOT been changed into an underscore character !

    Notes :

    In comparison to the previous regexes, only the look-aheads of the second S/R, are slightly different :

    The positive look-ahead (?=[^@]*#) verifies that, from the cursor location, a # character, can be found further, on the current line scanned, without any @ character, between the cursor location and the # location

    The negative look-ahead (?![^#]*@) verifies that, from the cursor location, a @ character, cannot be found further, on the current line scanned, without any # character, between the cursor location and the @ location

    Cheers,

    guy038

  • New to notepad and html; work won't show up in browsers

    Locked
    3
    0 Votes
    3 Posts
    5k Views
    Ellen Brewer JohnE

    Thank you very much for your reply! I was able to sort out my issues.

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • search and select files that contains a particular languages

    Locked
    1
    0 Votes
    1 Posts
    999 Views
    No one has replied
  • Use regex to replace backspace by underscore

    Locked
    7
    0 Votes
    7 Posts
    9k Views
    Mauricio SalazarM

    Thank you, it worked well

    Best Regards

  • 0 Votes
    7 Posts
    5k Views
    Stefan1200S

    With Notepad++ v7 I still have this problems. Can someone help fixing this? Thanks in advance. :)

  • New file on "Folder as Workspace", is that a way?

    Locked
    1
    1 Votes
    1 Posts
    1k Views
    No one has replied
  • What is plugins for v7 x64?

    Locked
    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • See all files in save dialog

    Locked
    2
    0 Votes
    2 Posts
    2k Views
    Scott SumnerS

    If you don’t mind tripling the amount of typing, entering this in the “File name:” box and pressing Enter seems to achieve what you want:
    *.*

    It’s really just the “All types” mask, but quicker than choosing “All types (*.*)” from the dropdown.

    Cheezy solution, I know…but I use it myself, rather often. :)

  • Suddenly hangs and my file data is erased automatically

    Locked
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • What is "Open session in a new instance of Notepad++"?

    Locked
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • Open with NPP from a right-click on .htm file opens file in IE

    Locked
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Synchronised scrolling across all open files?

    Locked
    2
    0 Votes
    2 Posts
    2k Views
    Scott SumnerS

    How about the keyboard shortcut for moving to the end of document (default: Ctrl+End)? Sure, you’d have to do it in each document, but it is only one (quick) action…

  • Help with Notepad

    Locked
    3
    0 Votes
    3 Posts
    2k Views
    cipher-1024C

    Menu bar -> Language -> INI file

    You will probably get faster/better responses if you include more information about what you’re trying to do.

  • RegEx Replace button doesn't work as expected with a look-behind.

    Locked
    5
    1 Votes
    5 Posts
    3k Views
    dailD

    Title updated.

  • Regex: Double your words

    13
    0 Votes
    13 Posts
    9k Views
    guy038G

    Hello Glenn,

    Oh yes, Glenn you’re thousand times right ! I should have re-read my reply, before posting ! Sorry, for being approximative !

    So, given the S/R, below :

    SEARCH : (?-s)(?:.*\R){26}\K.*(?s)(.*)

    REPLACE : String replacing line 27\1

    Updated Notes :

    The in-line modifier (?-s) forces the regex engine to consider that the dot meta-character will match standard characters, only

    The non-capturing group, repeated 26 times, (?:.*\R){26} selects the first 26th complete lines, with their EOL characters, of each file

    The \K syntax suppresses that selection and reset the regex position of search between the last EOL character of line 26 and the first character of line 27

    Then the .* part, look for all the standard characters, even 0, of the 27th line, which have to be replaced

    Then, the in-line modifier (?s), now, forces the regex engine to consider that the dot meta-character will match any character ( standard OR End Of Line character )

    So, the final part, (.*), inside round parentheses, defines the group 1, containing all the text, from the EOL characters of line 27 … to the very end of the file

    In replacement, the expression String replacing line 27 represents, the new replacement text and the \1 syntax represents the text from the EOL characters of line 27 … to the very end of the file, which must be re-written without any change !

    With that work-around, glennfromiowa, I don’t need to write \r\n, in the replacement regex, for the EOL characters of the line 27 !!

    Many thanks again, for pointing out these approximations ! Indeed, from now on, I’ll have to be careful, because some people, like you, read my posts, word after word :-))

    Best Regards,

    guy038

    P.S. :

    As I’m a moderator of the Node BB Notepad++ forum, I’m going to update my previous post, about that topic , by adding a link to that present post ! So, anyone will, easily, see the differences :-)