如何在Perl中搜索和替换字符串中的非字符?

时间:2018-07-26 13:23:38

标签: regex perl

我有以下格式数据

$line1 = violation:start:CLK:a1.ID:end:a2.VALUE[22:0]:CLK1
$line2 = violation:start:CLK2:b1.ID[23:45]:end:b2.VALUE[2:03]:CLK3

因此,我如何搜索[\ d +:\ d +]并替换为[\ d +#\ d +]

例如:[22:0]至[22#0]

请帮助我!

1 个答案:

答案 0 :(得分:-1)

{
  "Id": "B5F18C84-4790-E811-80CC-005056BA0972",
  "RefId": "4532516",
  "InboundWeight": 0,
  "OutboundWeight": 4352,
  "Total": 4.75,
  "Surcharge": 0,
  "FlatRate": 130,
  "Credit": 0,
  "Surcharge2": 0,
  "Cwt": 0,
  "ChargeType": 155,
  "Key": "18981760",
  "ReferenceKey": "3003858587",
  "StopKey": "11792108",
  "RawTotal": 4.75,
  "ChargetTypeKey": "SANITIZED",
  "ChargeTypeDescription": "SANITIZED",
  "RawWeight": 4352,
  "Header_Id": "B4F18C84-4790-E811-80CC-005056BA0972"
}