Regular Expression for Finding URL (ending with FLV/flv)
I need to get all instances of http://someurl/somefile.flv within a HTML file. Extension must not be case sensitive.
I currently use the following simple regular expression that I use in Javascript:
var rePattern = new RegExp(
"(http://.*.flv)",
"gi"
);
It has it's fl开发者_如何转开发aws though, especially if there is a URL and somewhere further in the file you have something mentioning FLV.
I've found various regular expressions that check for URLs, etc but I cannot correctly modify them to just search for FLV links.
/http:\/\/[\S]+?\.flv/g
document.body.innerHTML.match(/http:\/\/[\S]+?\.flv/g)
If I were doing this, my regexp would look something like:
http:\/\/(.+)\.(.+)\.flv
I escaped my special characters, as you should do. Specifically, the two slashes, and the period right before "flv". Your regexp would incorrectly match "http://123flv" which I'm sure you don't want. My version also requires a top-level-domain, e.g., example.com. Yours would have matched http://example/x.flv which clearly isn't a valid URL. Notice, also, how I use the + instead of *, to ensure that one or more characters is present.
Hope this helps.
-tjw
http://[^\"\'<>{}\s]{6,255}(?<=.flv)
精彩评论