I try to write regex to match URL in Java. I found the regex on the internet and it works fine in the online regex editor.
When i try to run it on the eclipse, it gives following error : Invalid escape sequence (valid ones are \b \t \n \f \r \” \’ \ )
(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?
How can i solve this problem?
Thanks in advance.
Note that in Java strings you have to escape backslashes (i.e.
\would result in the string literal"\\"). Thus the expression should look like this: