我正在尝试将以下格式DECLARE @Person VARCHAR(255)
SET @Person = 'Person'
print '----------------------------------------------------------------------------------------------------'
if object_id(@Person, 'U') is not null
begin
print ' Tabelle ' + @Person + ' wird entfernt'
execute('drop table ' + @Person)
end
GO
捕获到preg_match_all返回的相同键值中。
这就是我提出的:
1 1/4
输出:
<strong>1 1/2 lbs</strong> fish
<strong>⅛ cup</strong> peppers
<strong>1-2 tbsp</strong> olive Oil
preg_match_all("/[\d+↉½⅓⅔¼¾⅕⅖⅗⅘⅙⅚⅐⅛⅜⅝⅞⅑⅒⅟](?:\/\d+?)?(?:-?\d+)?(?: \/\d+)?/u", $input_lines, $output_array);
但它应该是:
0 => array(
0 => 1
1 => 1/2
2 => ⅛
3 => 1-2
)
)
答案 0 :(得分:1)
(?:[ \-\/]*[\d↉½⅓⅔¼¾⅕⅖⅗⅘⅙⅚⅐⅛⅜⅝⅞⅑⅒⅟]+)+
匹配您的示例并匹配
之类的字符串<strong>15½ cup</strong> peppers
<strong>14½-17 cup</strong> peppers
<strong>15 1/2 - 16 tbsp</strong> Oil
<strong>1½</strong> Oil
太
如果你想避免<strong>1 1/2 lbs</strong> f15h
的双重匹配,你可以检查带有正面背后的“强”标签
(?<=<strong>)(?:[ \-\/]*[\d↉½⅓⅔¼¾⅕⅖⅗⅘⅙⅚⅐⅛⅜⅝⅞⅑⅒⅟]+)+