this question has answer here:
- regex dropping http:// , www. urls 4 answers
i have never used regex before , have been asked remove scheme url. make transform url http://www.foo.com //www.foo.com.
i wondering whether possible? , know if knew tutorials or website me absolute beginner.
thanks can give.
you basic string manipulation, , recommend on regex.
however if insist on using regex, here's regex if combined regex replace of whichever language using:
^http: ^\ / | \ / | `- match string literally | `- match @ start of string if you're going remove https: this:
^https?: ^\ /^^^ | \/ ||| | | ||`- literally match `:` | | |`- previous optional (literal s) | | `- literally match s | `- match string literally | `- match @ start of string these assume checking exact urls, if you'd check anywhere in string, replace ^ anchor (beginnning of string) \b word boundary:
\bhttps?: \/\ /^^^ | \/ ||| | | ||`- literally match `:` | | |`- previous optional (literal s) | | `- literally match s | `- match string literally | `- word boundary (typically whitespace, `][` , on make regex replace matches pattern '' (empty string). recommend adding i flag case-insensitive matching.
here's tutorial site on regular expressions: http://www.regular-expressions.info/
Comments
Post a Comment