[英]Regular Expression (Hyphens, Underscores, and Periods)
I need a regular expression that will be able to detect: 我需要一个能够检测到的正则表达式:
https://s-dPICS-sac323.domain.com/a12_hyJ_k87ds_x.jpg
Will this code do it: 这段代码会这样做吗:
var x = /(https:\/\/[A-Za-z0-9.-]*PICS[A-Za-z0-9._\/]*\.jpg)/g;
Will this be able to detect something along the lines of: 这是否能够检测到以下内容:
Note: everything except https:// , PICS , domain.com , and .jpg are random alpha-numeric characters for this example. 注:除HTTPS一切://,PICS,domain.com,和.jpg是这个例子随机字母数字字符。 I'm trying to detect all of the rest of the characters.
我正试图检测所有剩下的角色。
Thanks for your help! 谢谢你的帮助!
Try this instead: 试试这个:
/https:\/\/[a-z0-9.-]*photos[\w.\/-]*\.jpg/i
Demo: http://rubular.com/r/flmf92C3T2 演示: http : //rubular.com/r/flmf92C3T2
不要逃避正常斜线,它们不是魔法角色。
/https:\/\/[\w.-]+PICS[\w.\/-]+\.domain\.com/[\w.\/-]+\.jpg/
/(https:\\/\\/[A-z0-9.-]*PICS[A-z0-9.-]*domain\\.com[A-z0-9.-/_]*\\.jpg)/
will match "https://s-dPICS-sac323.domain.com/a12_hyJ_k87ds_x.jpg". /(https:\\/\\/[A-z0-9.-]*PICS[A-z0-9.-]*domain\\.com[A-z0-9.-/_]*\\.jpg)/
将匹配“https://s-dPICS-sac323.domain.com/a12_hyJ_k87ds_x.jpg”。
And /(https:\\/\\/[A-z0-9.-]*photos[A-z0-9/.-]*\\.jpg)/
will match "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc3/12868_695309462154_5301742_40115272_5760577_n.jpg" with https:// , photos , and .jpg being constant. 和
/(https:\\/\\/[A-z0-9.-]*photos[A-z0-9/.-]*\\.jpg)/
将匹配“https://fbcdn-sphotos-a.akamaihd .net / hphotos-ak-snc3 / 12868_695309462154_5301742_40115272_5760577_n.jpg“与https:// , 照片和.jpg保持不变。
Is there something more you need out of it? 你还需要更多东西吗? Give it a try at regexpal.com
试试看regexpal.com吧
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.