weekapaug
asked on
Regex HELP
Hi, if I know most of a url but just need help telling it to get everything until it sees the extension, how can I do that?
For instance, I would want to retrieve any urls that start with "http://www.getthisURL.com"
Some of the references in the string might be http://www.getthisurl.com/1/file1.txt
and others might be http://www.getthisurl.com/1/differentFolder/file1.txt
If I know what they start with and know they always end with .txt how can I make a regex to get the string from my known starting value until it encounters .txt no matter how many folders are in between and then end?
I was using this
https://www.getthisURL.com/folder1/.*?(txt)
and it worked when its only one folder deep and I know the name of said folder but what I need the contents between the .com/ and get everything until it sees .txt?
For instance, I would want to retrieve any urls that start with "http://www.getthisURL.com"
Some of the references in the string might be http://www.getthisurl.com/1/file1.txt
and others might be http://www.getthisurl.com/1/differentFolder/file1.txt
If I know what they start with and know they always end with .txt how can I make a regex to get the string from my known starting value until it encounters .txt no matter how many folders are in between and then end?
I was using this
https://www.getthisURL.com/folder1/.*?(txt)
and it worked when its only one folder deep and I know the name of said folder but what I need the contents between the .com/ and get everything until it sees .txt?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
https://www.getthisurl.com/.*?(txt)
I was also able to further refine like this
https://www.getthisurl.com/.*?(txt|doc) to find other extensions in any folder after the first slash
I will post another question for a new regex, the next one is trickier. I've been reading tutorials but I'm still missing something to make it filter correctly.