Forum Replies Created
- AuthorPosts
- Mr KTParticipant
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]Mr KTParticipantThis 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
August 19, 2019 at 8:13 am in reply to: Regex expression to back reference more than 9 values in a replace? #26115Mr KTParticipantThanks 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 nameAugust 1, 2019 at 9:46 am in reply to: Regex expression to back reference more than 9 values in a replace? #26048Mr KTParticipantYes 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>
July 5, 2019 at 2:14 pm in reply to: Multiple-line string as a search string in the Find/Replace dialog box #25955Mr KTParticipantHi 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 4Mr KTParticipantSure, 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\3Mr KTParticipantTry this Spiros;
Find:
(\{\{grml\r?\n)(.*?\r?\n)(\}\}\n?)(\{\{grml\r?\n)\2(\}\}\n?)Replace With:
\1\2\3Mr KTParticipantHello 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).Mr KTParticipantHey 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;
}Mr KTParticipantHi 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).
Mr KTParticipantI 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 lines2) 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 linesShould be trivial to create macro for these.
August 28, 2018 at 9:12 am in reply to: Question of Regular Expression for matching multi-row #23634Mr KTParticipantAssuming 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:
somethingSelect 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?)Mr KTParticipantI’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.
June 17, 2017 at 11:42 am in reply to: Software Wish – Display the column number more visually in CSV/TSV mode #21983Mr KTParticipantI 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.
October 14, 2014 at 10:56 am in reply to: Macro search/replace scope based on whether any text is highlighted #19443Mr KTParticipantFantastic!
Thank you Yutaka.October 14, 2014 at 2:59 am in reply to: Macro search/replace scope based on whether any text is highlighted #19437Mr KTParticipantThanks 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.
- AuthorPosts