【发布时间】:2015-10-10 19:28:06
【问题描述】:
我正在尝试构建一个将第一次从字符串中提取出来的正则表达式。
问题是时间格式不规范。
以下是可能的变化。
':' with 1 hour digit before the ':' (ex. 9:00 pm)
':' with 2 hour digits before the ':' (ex. 10:00pm)
no minutes with with 1 hour digit (ex 9pm)
no minutes with with 1 hour digit (ex 10pm)
另外,“am”或“pm”之前可能有也可能没有空格
这是一个示例字符串。
7:30 pm -9 pm Lorem Ipsum is simply dummy text. 9pm-10pm Lorem Ipsum is simply dummy text
我希望这个字符串返回"7:30 pm"
【问题讨论】: