regex find count
var strAnswer = prompt( "find waht ?", "w+" ); var count=0; while ( document.selection.Find( strAnswer, eeFindNext | eeFindReplaceRegExp) ) { count++; } OutputBar.Clear(); OutputBar.writeln( "find count: "+count ); OutputBar.Visible = true; OutputBar.SetFocus(); serach document by regex which you input,find and print match counts
Good example of utilizing "OutputBar", thanks.
If you are interested, you can modify your script with some details like shown here:
// do not update the screen during our work:
Redraw = false;
// get and store current cursor position:
yPos = document.selection.GetActivePointY( eePosLogical );
xPos = document.selection.GetActivePointX( eePosLogical );
// ask the user:
var strAnswer = prompt( "find what ?", "\\w+" );
// do the work; search for occurrences:
var count=0;
while ( document.selection.Find( strAnswer, eeFindNext | eeFindReplaceRegExp) )
{ count++; }
// provide the result to the output bar:
OutputBar.Clear();
OutputBar.writeln( "find count for \"" + strAnswer + '\" after column '
+ xPos + ' of row ' + yPos + ': ' + count );
OutputBar.Visible = true; OutputBar.SetFocus();
// erase search highlighting:
document.HighlightFind = false;
// go back to origin cursor position:
document.selection.SetActivePoint( eePosLogical, xPos, yPos, false );
Keep up! ;-)2 posts in this topic