- AuthorPosts
- September 19, 2012 at 12:12 pm #10548userParticipant
hello!
how can I return the number of found regex matches?
how can I select the regex matches?
thanks!
September 21, 2012 at 12:03 am #10549Yutaka EmuraKeymasterHello,
Is this about macros?
Thanks!
April 10, 2013 at 10:23 am #10930userParticipantI am not sure
I just want to have these options when I do a regex search
is it possible?
thanks!!!
April 10, 2013 at 2:09 pm #10931StefanParticipantuser wrote:
count all the regex matches
I just want to have these options when I do a regex searchYou can check “[X] Count Matches” and click at [Find Next]
to see the count in the status bar.user wrote:
select all the regex matches
I just want to have these options when I do a regex searchYou can click at [Bookmark All]
and then utilize “Edit > Bookmarks”Or use a script/macro to collect all matches.
In the Library you can find e.g. “Macro to extract strings using regular expression”April 10, 2013 at 6:43 pm #10937StefanParticipantuser wrote:
hello!how can I return the number of found regex matches?
how can I select the regex matches?
thanks!
One could utilize a macro like this basic example:
//Text to parse for RegEx:
selText = document.selection.text;
//Show matches:
vResults = findMatches(selText);
alert(vResults);
function findMatches(inputStr){
//Build an expression to match what you want:
//var regex = /dddd/ig; // match 2013
var regex = /www..+?..{2,3}/ig; //match www.emeditor.com
//To avoid errors, check beforehand if test is successful:
if(regex.test(inputStr)){
//if test was ok, collect matches:
result= inputStr.match(regex);
//some cosmetic:
count = result.length;
status = "Macro found " + count + " matches.";
//return result to caller:
return result.join("rn");
}else{
return "No match found.";
}
}_
April 10, 2013 at 7:00 pm #10940userParticipantit’s great, many thanks!
- AuthorPosts
- You must be logged in to reply to this topic.