count and select all the regex matches

Started by: user3 voices6 posts

hello!

how can I return the number of found regex matches?

how can I select the regex matches?

thanks!
Hello,

Is this about macros?

Thanks!
I am not sure

I just want to have these options when I do a regex search

is it possible?

thanks!!!

user wrote:
count all the regex matches
I just want to have these options when I do a regex search

You 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 search

You 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"

user 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 emeditor.wpengine.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.";
}
}



_
it's great, many thanks!

6 posts in this topic