简体   繁体   English

正则表达式(连字符,下划线和句点)

[英]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.

相关问题 正则表达式:仅限字母、数字、空格、连字符、句点和下划线,并且必须以字母开头 - Regular Expression: Letters, numbers, spaces, hyphens, periods, and underscores only and must begin with a letter 正则表达式字母数字字符-允许连字符和下划线 - regular expression alphanumeric characters - allowing hyphens and underscores javascript正则表达式,以允许字母,数字,句点,连字符,下划线和空格 - javascript regex to allow letters, numbers, periods, hyphens, underscores, and spaces 修复电子邮件的正则表达式不允许连续的时间段 - Fix Regular Expression for Emails to Not allow Consecutive Periods JavaScript正则表达式可用于单词边界,可忍受单词内的连字符和撇号 - JavaScript regular expression for word boundaries, tolerating in-word hyphens and apostrophes 正则表达式 - 允许使用字母,撇号,句号,逗号和连字符 - Regular Expression - letters, apostrophes, full stops, commas and hyphens are allowed 正则表达式X个字符长,字母数字,但不包括_和句点,但不包括开头或结尾 - Regular expression X characters long, alphanumeric but not _ and periods, but not at beginning or end Javascript 正则表达式按句点分割字符串,不在双引号中 - Javascript regular expression split string by periods not in double quotes Javascript正则表达式:匹配所有字母数字字符,除所有空白外,允许使用破折号和下划线 - Javascript regular expression: Match all alphanumeric characters, allow dashes spaces and underscores except all whitespace 正则表达式只允许两个下划线,没有其他特殊符号并且前一个或下一个字符应该是数字或字母 - Regular expression to allow only two underscores, absence of other special symbols and previous or next character should number or letter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM