Oracle11g正则表达式非捕获组 多货币REGEXP\u SUBSTR Oracle11g
第一次在这里发帖,所以我希望我不要把它搞得太糟 我创建了一个查询,用于提取各种客户订单详细信息,包括收费价格、产品清单价格和大的价格,即通过提醒电子邮件发送给客户的价格 使用REGEXP_SUBSTR,我能够以各种货币匹配电子邮件HTML内容中的所有价格,但我遇到了一个问题,即某些价格货币缩写组合的输出缺少逗号或句点:即123 kr、999比索或1050 Kč 如何使上述情景与其他价格格式的输出相匹配? 我从加里的回答中获得了很多“灵感”: 数据源HTML 从Oracle11g正则表达式非捕获组 多货币REGEXP\u SUBSTR Oracle11g,regex,oracle11g,currency,regex-group,regexp-substr,Regex,Oracle11g,Currency,Regex Group,Regexp Substr,第一次在这里发帖,所以我希望我不要把它搞得太糟 我创建了一个查询,用于提取各种客户订单详细信息,包括收费价格、产品清单价格和大的价格,即通过提醒电子邮件发送给客户的价格 使用REGEXP_SUBSTR,我能够以各种货币匹配电子邮件HTML内容中的所有价格,但我遇到了一个问题,即某些价格货币缩写组合的输出缺少逗号或句点:即123 kr、999比索或1050 Kč 如何使上述情景与其他价格格式的输出相匹配? 我从加里的回答中获得了很多“灵感”: 数据源HTML 从开始的所需值: 匹配所有的 1.4
开始的所需值:
匹配所有的
- 1.4“>19.99美元(一些随机文本)
- 1.4“>20.00雷亚尔
- 1.4“>20.00欧元
- 1.4“>25,99欧元
- 1.4英寸>15.99英镑
- 1.4“>123 kr
- 1.4英寸>1234英尺
- 1.4“>999比索
- 19.99
- 20.00
- 20.00
- 25.99
- 15.99
- 123韩元
- 1234英尺
- 999比索
我意识到这可能是由于我拥有多个捕获组,因此我看到了三种可能的解决方案:
SQL 这是一个完整的语句,其中包含两个嵌套的REPLACE函数,用于将输出格式化为系统格式
- 请参见此处正在运行的正则表达式:李>
尼克实际的问题是什么?你试过使用简单的regexp\u替换吗?你能给我们展示一个存储在nnc.MESSAGE中的示例吗(显然是清理任何私人数据)?我很感激你的努力,但你在这里没有问任何问题。这只是一个关于正则表达式的大量信息集合。未来的提示:如果你没有在帖子的结尾加上“?”,你应该继续编辑。哇,我想我醒得太晚了…抱歉,修正了@grail我认为REGEXP_REPLACE在这里没有帮助,因为我能够匹配所有价格并以正确的格式返回大多数场景。我可以试着发布一个内容示例,但实际上我将从今晚开始离开键盘两周。几个示例将非常有帮助,因为您的正则表达式非常混乱,也不会像预期的那样执行,例如点\d+(\d{1,4})*,因为正则表达式很贪婪,第一个\d上的加号将消化所有数字,这样分组的数字就不会因为后面的零或多个限制而包含任何内容。充其量,如果该组强制至少一个数字,这将是由于之前的限制而获得的最大值。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thank you for using us</title>
<style type="text/css">
.ReadMsgBody {
width: 100%;
}
.ExternalClass {
width: 100%;
}
BODY {
font-family: OpenSans, Arial, Helvetica, sans-serif;
font-size:13px;
color:#555555;
}
TD {
font-family: OpenSans, Arial, Helvetica, sans-serif;
font-size:13px;
color:#555555;
vertical-align: top;
}
A {
color: #f48024;
}
IMG {
display:block;
border: none;
}
H1 {
font-size: 18pt;
}
H2 {
font-size: 15pt;
}
H1, H2, H3, P, UL, LI {
margin: 0;
padding: 0;
}
</style>
</head>
<body style="margin: 0; padding: 0; background-color: #eeeeee" bgcolor="#eeeeee">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin: 0; padding: 0; ">
<tbody>
<tr>
<td align="center" width="100%" >
<!-- TOP-->
<table bgcolor="#eeeeee" border="0" cellpadding="0" cellspacing="0" style="background-color: #eeeeee; width:100%; max-width:900px; ">
<tbody>
<tr>
<td height="34" style="font-size: 1px;"><!-- cell --></td>
</tr>
</tbody>
</table>
<!-- END TOP-->
<!-- LOGO -->
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff" style="width:100%; background-color: #fff; max-width:900px;">
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff" style="background-color: #fff; text-align: center; max-width:650px;">
<tr>
<td align="center" height="40" bgcolor="#fff" style="background-color: #fff; vertical-align: middle; text-align: center; ">
<a href="https://www.company.com/" target="_blank"><img align="center" style="" src="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded" style="display:block" alt="" /></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END LOGO-->
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff" style="width:100%; max-width:900px; background-color: #fff;">
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff" style="width:100%; background-color: #fff; max-width:800px; padding-left:10px; padding-right:10px;">
<tr>
<td height="30" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: center; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:22px; color:#41424e; line-height: 1.4"><b>Example Template</b></p>
</td>
</tr>
<tr>
<td height="34" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#767683; line-height: 1.4">Dear customername,</p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#767683; line-height: 1.4">Your productname - 1PC has been successfully renewed.</p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#767683; line-height: 1.4">Details of your sub below.</p>
</td>
</tr>
<tr>
<td height="40" style="font-size: 1px;"><!-- cell --></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- sum-->
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#F2F2F6" style="width:100%; background-color: #F2F2F6; max-width:900px;">
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#F2F2F6" style="width:100%; background-color: #F2F2F6; max-width:800px; padding-left:10px; padding-right:10px;">
<tr>
<td height="34" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: center; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:20px; color:#41424e; line-height: 1.4"><b>Your Auto-Renewal Sub</b></p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#42ba8f; line-height: 1.4"><b>Product</b></p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">Productname - 1 PC</p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#42ba8f; line-height: 1.4"><b>Order ID</b></p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">12131415161</p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#42ba8f; line-height: 1.4"><b>Exp Prices charged</b></p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<!--START Price Exp, templates could be in numerous different languages but info like i.e. customername, productname, Order ID, Tracking IDs will always use the same format. -->
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">$69.99 (a tax message)</p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">123 kr (b tax message)</p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">999 Pesos (c tax message)</p>
</td>
</tr>
<!--END Price Exps -->
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#42ba8f; line-height: 1.4"><b>Automatically renewed</b></p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">May 20, 2018</p>
</td>
</tr>
<tr>
<td height="42" style="font-size: 1px;"><!-- cell --></td>
</tr>
</table>
</td>
</tr>
</table>
<!--END sum -->
<!-- white-->
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff" style="width:100%; max-width:900px; background-color: #fff;">
<tr>
<td height="15" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff" style="width:100%; background-color: #fff; max-width:800px; padding-left:10px; padding-right:10px;">
<tr>
<td height="30" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">If you’d like to check your order status, please sign in to <a href="https://www.company.com/en-us/order?pgm=6916670010" target="_blank">company.com/orders</a> with the login credentials below.</p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4"><b>Order ID:</b> 12131415161</p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4"><b>Password:</b> stAcKoverFlOwrocks</p>
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#42ba8f; line-height: 1.4"><b>Your Plan</b></p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4"><strong>Auto-Renewal Terms</strong><p>By completing your purchase, you have authorized us to do a bunch of legal stuff.</p>
</td>
</tr>
<tr>
<td height="30" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4"><b>Need help?</b></p>
</td>
</tr>
<tr>
<td height="1" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td style="vertical-align: middle;">
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4"><a href="https://company.com/en_US/support" target="_blank">company.com/help</a></p>
</td>
</tr>
<tr>
<td height="30" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#41424e; line-height: 1.4">Thanks for trusting us.</p>
</td>
</tr>
<tr>
<td height="34" style="font-size: 1px;"><!-- cell --></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END white -->
<!--FOOTER-->
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#777684" style="width:100%; background-color: #E7E7EF; max-width:900px;">
<tr>
<td height="30" style="font-size: 1px;"><!-- cell --></td>
</tr>
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="#777684" style="width:100%; background-color: #E7E7EF; max-width:900px;">
<tr>
<td>
<table><tr><td>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:14px; color:#767683; line-height: 1.4">Trouble installing? <u><a href="https://www.company.com/en-us/faq.php" target="_blank">Visit FAQ</a></u></p>
<p style="text-align: left; margin:0; padding: 0; font-family: Arial, Helvetica, sans-serif; font-size:14px; color:#767683; line-height: 1.4">Curious for more? <u><a href="https://www.company.com/en-us" target="_blank">Find more</a></u></p>
</td></tr></table>
</td>
<td>
<table align="right" >
</tr> </table>
</td>
</tr>
<tr>
<td height="30" style="font-size: 1px;"><!-- cell --></td>
</tr>
</table>
</td>
</tr>
</table>
<!--END FOOTER -->
</td>
</tr>
</tbody>
</table>
</body>
</html>
(NT\$|SAR)\s(\d{2,5})|\d{1,4}([.,]\d{3})*([\s.,]\d{2,3}|[^\W]\d+(\d{1,4})*\s(kr|zł|Pesos|Kč|Ft|บาท|SAR|₪))
SELECT
REPLACE(REPLACE(REGEXP_SUBSTR(nnc.MESSAGE, '(NT\$|SAR)\s(\d{2,5})|\d{1,4}([.,]\d{3})*([\s.,]\d{2,3}|[^\W]\d+(\d{1,4})*\s(kr|zł|Pesos|Kč|Ft|บาท|SAR|₪))'),',','.'),' ','') AS EMAIL_PRICE_SENT
FROM tablename
WHERE clause;