正则表达式比赛,星期四,星期四,星期四,星期四 [英] regular expression match Thursday, Thurs, Thur,Thu
问题描述
我想要一个正则表达式来匹配部分工作日名称.例如,我要匹配星期四",星期四",星期四"或星期四".我尝试了"thu(rsday)?",但是只匹配了"thu"和"thursday".匹配缩写工作日的完整正则表达式将过长.我尝试过此正则表达式字符串:
I want a regexp to match partial weekday names. For example, I want to match "Thursday", "thurs", "thur" or "Thu". I tried "thu(rsday)?", but that only matched "thu" and "thursday". The complete regular expression to match abbreviated weekdays would be excessively long. I tried this regex string:
周一(周日)?|周二(周日)?|周三(周日)?|周四(周日)?|周五(周日)?|周六(周日)?|周日(周日)?
Mon(day)?|Tue(sday)?|Wed(nesday)?|Thu(rsday)?|Fri(day)?|Sat(urday)?|Sun(day)?
我的字符串看起来像这样:
The strings I have look like this:
3-Dec星期一1:00 pm首映USPHL Sk3-Red
3-Dec Mon 1:00pm Premiere USPHL Sk3-Red
4-Dec星期二8:10 pm U16 USPHL Sk3-Red
4-Dec Tue 8:10pm U16 USPHL Sk3-Red
6-Dec Thur 1:00 pm首映USPHL Sk3-Red
6-Dec Thur 1:00pm Premiere USPHL Sk3-Red
推荐答案
在Oracle中,我想在此位置选择字符串与工作日的位置匹配.我怀疑您可以调整正则表达式以适合您的环境:
In Oracle I'd do this where I want to select where the string matches a weekday. I suspect you can tweak the regular expression to fit your environment:
with tbl(str) as (
select '3-Dec Mon 1:00pm Premiere USPHL Sk3-Red' from dual union all
select '4-Dec Tues 8:10pm U16 USPHL Sk3-Red' from dual union all
select '6-Dec Thursday 1:00pm Premiere USPHL Sk3-Red' from dual
)
select str
from tbl
where regexp_like(str, ' (mon|tue(s)?|wed(nes)?|Thu(r)?(s)?|fri|sat(ur)?|sun)(day)? ', 'i');
这篇关于正则表达式比赛,星期四,星期四,星期四,星期四的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!