简体   繁体   中英

RegEx: need to automatically direct downloads from URL with changing section

I have no knowledge of RegEx code but I've just downloaded a Google Chrome extension that lets me automatically direct downloads to specific folders on my computer.

I want jpgs from a stock photo website to be downloaded in a specific folder, but part of the URL changes for every single file. how do I write out the File URL so it ignores the random section of the URL?

https://website.com/photos/IGNORE THIS PART with azAZ01 RANDOM CODE/download?force=true

Your question was a little confusing to me, but this should be the regex you need: https://website.com/photos/(\\w|\\d)*

To help break it down, the basic text (eg https:, website.com, photos) just matches with the raw text. The / thing is an escape character '\\' followed by the slash we want. Then for the random part, I'm assuming it's made up of letters and numbers, so that last part translates roughly to, any letter '\\w' or any number '\\d', and the * means any number of those.

Also, you can use Regex101.com as a helpful tool when making regex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM