简体   繁体   English

RegEx:需要通过更改部分自动从URL下载

[英]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. 我不了解RegEx代码,但我刚刚下载了一个Google Chrome扩展程序,可以让我自动将其下载到我计算机上的特定文件夹中。

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. 我希望将照片网站上的jpgs下载到特定文件夹中,但每个文件的URL部分都会更改。 how do I write out the File URL so it ignores the random section of the URL? 如何写出文件URL,以便忽略URL的随机部分?

https://website.com/photos/IGNORE THIS PART with azAZ01 RANDOM CODE/download?force=true https://website.com/photos/IGNORE此部分与azAZ01随机代码/下载?force = true

Your question was a little confusing to me, but this should be the regex you need: https://website.com/photos/(\\w|\\d)* 您的问题对我来说有点混乱,但这应该是您需要的正则表达式:https://website.com/photos/ (\\\\|||)*

To help break it down, the basic text (eg https:, website.com, photos) just matches with the raw text. 为了帮助分解它,基本文本(例如https:,website.com,照片)只是与原始文本匹配。 The / thing is an escape character '\\' followed by the slash we want. / thing是一个转义字符'\\',后跟我们想要的斜杠。 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. 然后对于随机部分,我假设它由字母和数字组成,因此最后一部分大致翻译为,任何字母'\\ w'或任何数字'\\ d',*表示任意数量的那些。

Also, you can use Regex101.com as a helpful tool when making regex 此外,在制作正则表达式时,您可以使用Regex101.com作为有用的工具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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