I’ve already tried my best but regular expressions aren’t really my thing. 🙁
I need to extract certain URLs that end in a certain file extension. For example, I want to be able to parse a large paragraph and extract all URLs that end with *.txt. So for example,
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla hendrerit aliquet erat at ultrices. Donec eu nunc nec nibh http://www.somesite.com/somefolder/blahblah/etc/something.txt iaculis dictum. Quisque nisi neque, vulputate quis pellentesque blandit, faucibus eget nisl.
I need to be able to take http://www.somesite.com/somefolder/blahblah/etc/something.txt out of the above paragraph but the number of URLs to extract will vary. It will be dynamic based on what the user inputs. It can have 3 links that end with *.txt and 3 links that don’t end with *.txt. I only need to extract those that does end in *.txt. Can anyone possibly give me the code I need for this?
You can find what you need with
/(?<=\s)http:\/\/\S+\.txt(?=\s)/Which means: