regex - How to detect a Url is BookMark Format -


help

i want open url in new window ,bookmarkformt url open in current webbrowser

i have simple way detect bookmark format url

file:///d:/administrator/desktop/123.htm#222

which contain .htm# or .htm#

this correct bookmark format url

// bookmark name 222

file:///d:/administrator/desktop/123.htm#222

// bookmark name ##abc

file:///d:/administrator/desktop/123.htm###abc

// bookmark name //.htm##.htm#abc#.html##//

file:///d:/administrator/desktop/123.htm#//.htm##.htm#abc#.html##//

how detect url bookmark format? regularexpressions can solve this,i can not write corrent regex?

this solution, need dectect url bookmark format

string htmfilename = @"d:\administrator\desktop\123.htm"; private void form1_load(object sender, eventargs e) {     webbrowser1.statustextchanged += new eventhandler(webbrowser1_statustextchanged);     webbrowser1.navigate(htmfilename);     navigated = true; }   private void webbrowser1_statustextchanged(object sender, eventargs e) {     textbox1.text = webbrowser1.statustext; }  //webbrowser1  navigating first time not open in new window bool navigated = false; private void webbrowser1_navigating(object sender, webbrowsernavigatingeventargs e) {     //first time nagivate      if (navigated == true)     {         //  url not bookmark format          // open in new window         if (e.url.tostring().contains(".htm#") == false)         {             e.cancel = true;             //webbrowser1.navigate(e.url, true);              //process.start bettor webbrowser1.navigate(e.url, true);             //because when url directory link such "file:///c:/"             //webbrowser open blank window , open directory              system.diagnostics.process.start(e.url.tostring());         }     }     textbox2.text = e.url.tostring(); } 

the below regex match correct bookmark format,

file:\/\/\/[^\.]*\.(?:htm|html)#+.* 

demo

or

file:\/\/\/d:\/administrator\/desktop\/123\.htm#.* 

demo


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -