Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Infinite loop in regex in java -


my purpose match kind of different urls:
url.com
my.url.com
my.extended.url.com
a.super.extended.url.com
, on...

so, decided build regex have letter or number @ start , end of url, , have infinite number of "subdomains" alphanumeric characters , dot. example, in "my.extended.url.com", "m" "my" first class of regex, "m" "com" last class of regex, , "y.", "extended." , "url." second class of regex.

using pattern , subject in code below, want find method return me false because url must not match, uses 100% of cpu , seems stay in infinite loop.

          string subject = "www.association-belgo-palestinienne-be";     pattern pattern = pattern.compile("^[a-za-z0-9]\\.?([a-za-z0-9_-]+\\.?)*[a-za-z0-9]\\.[a-za-z]{2,6}");      matcher m = pattern.matcher(subject);     system.out.println("    start");     boolean hasfind = m.find();     system.out.println("    finish : " + hasfind);    

which prints:

          start    

i can't reproduce problem using regex testers.
normal ? problem coming regex ?
due java version (1.6.0_22-b04 / jvm 64 bit 17.1-b03) ?

thanks in advance helping.

it's not infinite loop. problem it's checking every possible match , not finding one. if let run gazillion years, terminate. see this article explanation of what's happening under hood.

perhaps regular expression satisfactory (it terminates on given string): ^[a-za-z0-9][a-za-z0-9_-]*(\\.[a-za-z0-9_-]+)*\\.[a-za-z]{2,6}$ (see http://ideone.com/z0rlg)


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -