With regex in java, how do one put condition, i.e. if-then-else? Clearly say, I want to put condition if "http" exist, "www" CAN exist or if "http" doesnot exist "www" HAVE TO exist in the string. How can I implement that condition with regex?
What I done
((http){0,1}|(www){0,1})
But this is not work
example input :
if string starts with "http" after it, "www" can come.
ex: "httpwww < sometext >" --->should be matched
ex: "http < sometext >" --->should be matched
if string didnot start with "http", string have to start with "www"
ex: "www < sometext >" --->should be matched
ex: "< sometext >" ----> should not be matched by regex because it did not started with nor http and www
www, it did not start withhttp, but did start withwww(itself)!