Using Javascript to match regular expressions
Maybe you want try this at chrome's console:
var p=/.*(regu).+?\ /gi; console.log( document.body.innerText.match(p) );
Just open console, copy and paste above to console and hit enter. You can test it here at this page.
This can be improved if it fits in.
Here we print to console match indexes and matched text. Here we try to match text that contains regu
, 20 chars before (or less if start of line) and 10 chars after (or less if eol).
var p=/.{0,20}regu[^ \n]+[^\n]{0,10}/gi;
while (m = p.exec(document.body.innerText)) {
console.log( 'Index: '+m.index+' Match: '+m ); }
Also try this, it will paint background of all matches on page red, rexexp is not perfect but at least it should not mess with HTML tags:
var p=/(\>{1}[^\n\<]*?)([^\n\<]{0,30}regu[^\n\<]{0,10})/gi,b=document.body;
b.innerHTML=b.innerHTML.replace(p,'$1<span style="background-color:red;">$2</span>');
Bookmarking this:
Another way to use this is through javascript:
protocol (same code as just above):
javascript:(function(){var p=/(\>{1}[^\n\<]*?)([^\n\<]{0,30}regu[^\n\<]{0,10})/gi,b=document.body;b.innerHTML=b.innerHTML.replace(p,'$1<span style="background-color:red;">$2</span>');})();
For example, using javascript:
protocol one can insert a little search box to any web page for searching regexp's.
I think that you already know that simple regexp can also used to remove red matches from page.
If I continue to develop this for few more hours we may have search plugin that fit in bookmark :)
1
You don't use Firefox, but you might find one of its add-ons interesting: deeper web http://deeperweb.com/ It doesn't do REs, but it does assist finer grained searching. If you're really desperate, you could always save the source of a web page and then search it with a utility or editor that does support REs, but that would be pretty ugly.
– Joe – 2012-04-30T18:41:58.470maybe use NotePad++ as external editor for web pages. There you can search for regexps. – alfred – 2012-05-11T14:53:21.453