我有以下字符串,我想提取字符串的子集,包括日期。
以下是字符串的示例:
WITH cte
AS (
SELECT market_ticker
,Company_name
FROM Stocks
)
SELECT a.market_ticker
,b.Company_name
FROM cte a
INNER JOIN stocks b
ON a.market_ticker = b.market_ticker
GROUP BY a.market_ticker
,b.company_name
HAVING count(a.company_name) >= 2
ORDER BY 1
,2
我只想回来:
This is text written on 12/19/2017 10:03:38 AM
我尝试了以下(在许多其他尝试中):
This is text written on 12/19/2017
但似乎返回.+?(\d{1,2}/\d{2}/\d{4})
感谢您的任何见解!
答案 0 :(得分:2)
这应该有效。问题是“/”未在表达式中转义。
$pattern = "/<!-- bof_foo -->[.\n]*<!-- eof_foo -->/";