我需要从 SAP HANA 中的字符串中提取所有匹配的十进制数
文字:LOREN IPSUM DOLOR SIT AMET 73,89 X 339,85 X 0,08 CBC70° 1000/2,5
和
substr_regexpr('(\d(.*?)([\.\,]\d{1,3}))' in "Field" group 1
Run Code Online (Sandbox Code Playgroud)
我只从文本中提取了73,89。
和
\d(.*?)([\.\,]\d{1,3})+\d(.+?)([\,]\d{1,3})+\d(.*?)([\,]\d{1,3})
Run Code Online (Sandbox Code Playgroud)
我一起提取 3 个值:73,89 X 339,85 X 0,08
我需要提取它,但我无法这样做。
substr_regexpr('(\d(.*?)([\.\,]\d{1,3}))' in "Field" group 1 ==> 73,89
substr_regexpr('(\d(.*?)([\.\,]\d{1,3}))' in "Field" group 2 ==> 339,85
substr_regexpr('(\d(.*?)([\.\,]\d{1,3}))' in "Field" group 3 ==> 0,08
Run Code Online (Sandbox Code Playgroud)
谢谢!
要根据显示的示例获得 3 个捕获组,您可以尝试以下操作。
(?<=\s)(\d+(?:,\d+)?)\s+X\s+(\d+(?:,\d+)?)\s+X\s+(\d+(?:,\d+)?)
Run Code Online (Sandbox Code Playgroud)
说明:为以上添加详细说明。
(?<=\s) ##Checking look behind if spaces are present before next mentioned match.
(\d+(?:,\d+)?) ##Creating 1st capturing group to match digits and ,digits as optional.
\s+X\s+ ##Matching spaces(1 or more occurrences) X spaces(1 or more occurrences).
(\d+(?:,\d+)?) ##Creating 2nd capturing group to match digits and ,digits as optional.
\s+X\s+ ##Matching spaces(1 or more occurrences) X spaces(1 or more occurrences).
(\d+(?:,\d+)?) ##Creating 3rd capturing group to match digits and ,digits as optional.
Run Code Online (Sandbox Code Playgroud)