【发布时间】:2013-06-10 20:51:37
【问题描述】:
假设我有这个字符串:
For the AWSDataTransfer product, this is the public pricing plan.
Regarding data transfer across EC2 AZs:
In all AWS regions, inbound is $0.01/GB.
In all AWS regions, outbound is $0.01/GB.
我想将其更改为 JSON,如下所示:
{
"Product" : "AWSDataTransfer",
"PlanName" : "public",
"EC2Regional" : [
{"region" : "all", "type" : "in", "rate" : "0.01/GB"},
{"region" : "all", "type" : "out", "rate" : "0.01/GB"}
],
}
如何使用正则表达式来做到这一点。任何人都可以编写代码并帮助我。
【问题讨论】:
-
这可能需要一些复杂的解析。不确定是否适合只说:“嘿,给我一个正则表达式”。
-
对不起,字符串到底是什么?
-
这似乎是一个非常随意的字符串......