简体   繁体   English

编写正则表达式以查找特定类型网址的模式

[英]Write a regex to find pattern for a specific type of url

我有以下内容: "/assets/blt49012d3c84501502/CA_the_first_avenger.jpg"... "/assets/blt6d6c300f37d5df8c/husky_puppies.jpg"在巨大的字符串文本(json数据已字符串化)内,我不确定如何为其编写正则表达式,我试着做: /\\/assets\\/blt[a-zA-Z0-9]+/g但它只返回第一部分: /assets/blt49012d3c84501502谢谢!

I think this is the regex you are looking for: 我认为这是您要查找的正则表达式:

/(\/assets\/\w*?\/\w*?\.jpg)/g

You can test it out here 你可以在这里测试

This should do the trick -- 这应该可以解决问题-

\/assets\/blt[a-zA-Z0-9]+\/[\D|_]+\.jpg

https://regex101.com/r/aP4gI0/1 https://regex101.com/r/aP4gI0/1

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

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