Forum Replies Created

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • in reply to: Strip non printable characters #26204
    Mr KT
    Participant

    Hi harryray,

    This matches all ASCII characters (from space to tilde – not my solution)
    [ -~]

    By negating this, it now matches all NON-ASCII characters
    [^ -~]

    >>but what I’m after is something that will give me the choice of the characters to strip out as well as the non printable characters

    You should just be able to use alternation to add all the additional characters to strip out

    e.g. To strip out all NON-ASCII characters and all vowels:
    [^ -~]|[aeiou]

    in reply to: Match words/phrases between delimiting characters #26203
    Mr KT
    Participant

    This works for me (using version 19.1 which supports named groups):
    Find:
    ((?<=^)|(?<=, ))‘?(?<word_or_phrase>[^‘,’]+)’?
    Replace:
    [[\k<word_or_phrase>]]

    One of 2 possible positive lookbehinds, followed by your potential opening quote, then capture your word/phrase (which can’t include quotes or comma), check for potential closing quote

    Mr KT
    Participant

    Thanks Yutaka,
    $n seems to work great. Is it possible to implement named groups for Find and Replace, if the engine used is Onigmo? From the documentation (https://github.com/k-takata/Onigmo/blob/master/doc/RE), it seems as though it is supported?

    e.g: Section 8. Backreferences
    \k<name> \k’name’ backreference a group with the specified name

    Mr KT
    Participant

    Yes please, can I second this request. Also, if at all possible, if named groups could be used as named backreferences for replace, that would be fantastic.

    e.g. (Just a simple example but: ideally extended to more than 9 capture groups)

    Find: (?<day>\d\d)(?<month>\d\d)(?<year>\d\d\d\d)

    Replace: \k<year>\k<month>\k<day>

    Mr KT
    Participant

    Hi Tuska,
    try this (just with regular expressions radio button on):

    (?<![0-9])[24](?![0-9])

    Explanation:
    (?<![0-9]) means negative look-behind, check no number before 2 or 4
    [24] means find 2 or 4
    (?![0-9]) means negative look-ahead, check no number after 2 or 4

    in reply to: Matching previous group #24096
    Mr KT
    Participant

    Sure, just be aware that your last version, (\{\{grml\n.*?\n\}\}\n)\1 won’t match if a duplicate is the last line in the file (if there is no final “\n”). Otherwise it will do the job just fine.

    This should work in Notepad++/Emeditor (issue is with the way newline is represented, so “\r?\n” should handle this), and also work if the last line is the dupe.

    (\{\{grml\r?\n)(.*?\r?\n)(\}\}\r?\n?)(\{\{grml\r?\n)\2(\}\}\r?\n?)
    \1\2\3

    in reply to: Matching previous group #24094
    Mr KT
    Participant

    Try this Spiros;

    Find:
    (\{\{grml\r?\n)(.*?\r?\n)(\}\}\n?)(\{\{grml\r?\n)\2(\}\}\n?)

    Replace With:
    \1\2\3

    in reply to: Matching unopened tag #24091
    Mr KT
    Participant

    Hello Spiros,
    hopefuly i’ve understood the question – does this give you what you require?:

    With “Use Regualr Expressions ticked” and under “Advanced” – “^ and $ can Match beginning and End of the selection”

    Find:^([^<i>]*)</i>
    Replace with:\1
    “Replace All” until no more instances found).
    then
    Find:(</i>[^</i>]*)</i>
    Replace with:\1
    (again, “Replace All” until no more instances found).

    in reply to: Random Sort of data in CSV mode? #23828
    Mr KT
    Participant

    Hey David,
    I currently shuffle selected text using this macro. Hopefully does what you need or can be adapted fairly easily.

    if (document.CellMode == true ) {
    document.CellMode = false;
    }

    if( document.selection.IsEmpty ){
    // nothing is selected
    alert( “Select the text you want to shuffle\r\nIf this is a delimited file, select all text” );
    }
    else {
    strSelText = document.selection.Text;
    strLinebreak = “\r\n”;
    arrLinesArray = strSelText.split(strLinebreak);
    arrLinesArray.sort(function random(){return 0.5 – Math.random()});
    arrOut = arrLinesArray.join(strLinebreak);
    document.selection.Text = arrOut;
    }

    in reply to: Regex to extract digits only from a phone number #23781
    Mr KT
    Participant

    Hi BobBailey,
    Assuming you are running a fairly recent version of EmEd, try the following:

    Make sure your phone numbers are in a column (delimited file – e.g. tab, comma, etc.)
    Select this column.
    Search Menu – Replace (or Ctrl-H)
    In the Find field:([0-9])
    In the Replace with field:\0
    Make Sure the “Use Regular Expressions” and “In the Seleciton Only” check boxes are ticked.
    Click the Down arrow next to the Extract button and select “To New CSV Column”
    Click the Extract button.

    The phone numbers should be returned in a new column to the right of your original column (without punctuation).

    in reply to: select all lines containing a string #23656
    Mr KT
    Participant

    I typically use bookmarks for this scenario.

    1) select all lines containing string
    a. use the Find dialog box to search for string, click bookmark button
    b. Edit menu – bookmarks – Selected bookmarked lines

    2) select all lines NOT containing string
    a. use the Find dialog box to search for string, click bookmark button
    b. Edit menu – bookmarks – Invert bookmarks
    c. Edit menu – bookmarks – Selected bookmarked lines

    Should be trivial to create macro for these.

    in reply to: Question of Regular Expression for matching multi-row #23634
    Mr KT
    Participant

    Assuming you are running a recent version of EmEditor, try:
    Replace dialog box:
    Tick “Use Regular Expressions”

    Find:
    (?:function main takes nothing returns nothing)(.*?)(?:endfunction)
    Replace with:
    something

    Select the Advanced button:
    Tick “Regular Expression “.” Can Match Newline Character”
    Set the Additional Lines to Search for Regular Expressions to whatever number you need to match the largest block you want to replace (999?)

    in reply to: Freeze Pane Request #22675
    Mr KT
    Participant

    I’m often working with 50+ columns of data (which extends the single window view). Even if this isn’t a “complete” freeze option, the ability to always show the single left-most column would help massively in working with large multi-column data (where EE is much preferred over Excel). I was thinking an option when you right-click a column header and can toggle a “Freeze Column(s)” tick on/off, under the existing cut/copy/delete column(s) options. Hopefully not too difficult to implement.

    Mr KT
    Participant

    I would like to second this idea. As well as numerical/alphanumerical, if possible, it would also help if the font/size/colour of the column number could be user customizable.

    Mr KT
    Participant

    Fantastic!
    Thank you Yutaka.

    Mr KT
    Participant

    Thanks Yutaka,
    so to clarify – if I have a comma separated file as follows:
    _______
    A1,B1,
    A2,B2,
    A3,B3,
    etc.
    ________

    is there a way to run a SINGLE macro so if no text is selected, it will run on the entire file & produce this (just a simple example, searching for regexp start of line ^, replace with “):
    _______
    “A1,B1,
    “A2,B2,
    “A3,B3,
    etc.
    _______

    BUT if I am in CSV Mode (so the file is now in columns), highlight Column “B” and run the same macro, it will produce this:
    _______
    A1,”B1,
    A2,”B2,
    A3,”B3,
    etc.
    _______

    It seems there needs to be some way for the single macro to know if text is highlighted or not, before it can run on the whole file or just selected text?
    Would an additional flag that checks if text is selected first, then run the macro and it will work on that selection only, but if text isn’t selected, if will run on the whole file instead
    (e.g. eeReplaceSelOnly_else_eeReplaceall)?

    Thank you for your efforts.

Viewing 16 posts - 1 through 16 (of 16 total)