Regular expression Matching

Source: Internet
Author: User

The regular expression match was learned due to the need for work. The data text exported from MongoDB is roughly the same:

{
"_id": ObjectId ("55370b4112db760740809f79"),
"Cartkey": {
"CustomerId": Numberlong (471)
},
"Lastupdate": Isodate ("2015-06-04t08:21:24.307z"),
"Baskets": [{
"Items": [{
"SKU": "5170",
"CategoryName": "Cables & Adapters"
}],
"CountryCode": 32
}]
}

{
"_id": ObjectId ("55769cc512db760da847d639"),
"Cartkey": {
"CustomerId": Numberlong (1002)
},
"Lastupdate": Isodate ("2015-06-01t00:00:00z"),
"Baskets": [{
"Items": [{
"SKU": "2716",
"CategoryName": "IPhone iPad IPod"
}],
"CountryCode": 46
}]
}

{
"_id": ObjectId ("54b5e9d412db761c388d6c48"),
"Cartkey": {
"CustomerId": Numberlong (4398734)
},
"Lastupdate": Isodate ("2015-06-05t03:49:11.131z"),
"Baskets": [{
"Items": [{
"SKU": "33883",
"CategoryName": "Plugs & Sockets"
}, {
"SKU": "126095",
"CategoryName": "Household thermometers"
}],
"CountryCode": 46
}]
}

The goal is to convert "CustomerId": Numberlong (4398734) to "CustomerId": 4398734, "lastupdate": Isodate ("2015-06-05t03:49:11.131z") Convert to "lastupdate": "2015-06-05t03:49:11.131z",

I'm using a regular replacement of the notepad++ editor.

The regular expression to find the target is: "CustomerId": numberlong\ ((. *) \)

To be replaced by: "CustomerId": \1

The date is: "Lastupdate": isodate\ ((. *) \)

Replace with "Lastupdate": \1

Why is \1? Because we all know the reason for using () is because of group.

Series Articles:

http://zhoufoxcn.blog.51cto.com/792419/281956/

Http://www.crifan.com/files/doc/docbook/rec_soft_npp/release/htmls/npp_func_regex_replace.html

Regular expression Matching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.