Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
No Match

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r"(\/\/img(\d+))\.360buyimg\.com\/((\w+)[\w\/\.\-]*(jpg|gif|png|webp))" test_str = "[{\"type\":\"Page\",\"title\":\"页面容器\",\"isNative\":false,\"canPlace\":true,\"canNotDelete\":true,\"childrens\":[{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556185860618,\"uuid\":1556185860618,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc17cf7ee44bc2b3378bc40\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/33323/35/7388/497869/5cc184adEf5227645/d51d63a8207153fd.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":1,\"k\":1,\"showLingTemplate\":false,\"scene\":\"通栏_1556185860618\",\"LingBnIdArr\":[{\"tplId\":\"5cc17cf7ee44bc2b3378bc40\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc17cf7ee44bc2b3378bc40\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":1,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9c823f087e3f003f0f949a1557851692357\",\"title\":\"图片标题\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b9b6054d4e9ba41f11c0fd7.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b9b6054d4e9ba41f11c0fd7.png\",\"props\":{\"data-fkey\":1556185969829,\"uuid\":1556185969829,\"layoutType\":\"img\",\"title\":\"图片标题\",\"titleColor\":\"#333333\",\"titleIcon\":\"\",\"subtitle\":\"\",\"subtitleColor\":\"#666666\",\"titlePosition\":\"center\",\"bgColor\":\"#ffffff\",\"showExtra\":false,\"extraColor\":\"#999999\",\"extraType\":\"1\",\"extraContent\":\"\",\"bgImg\":[{\"url\":\"无须录入链接\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/43225/4/322/16558/5cc184d7Ea7f4d858/458ff339ae707c4c.png\",\"tplid\":\"5cc17d9112f16cde9ee7edbc\"}],\"key\":2,\"k\":2,\"showLingTemplate\":false,\"scene\":\"图片标题_1556185969829\",\"LingBnIdArr\":[{\"tplId\":\"5cc17d9112f16cde9ee7edbc\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"bgImg\"}],\"defaultPicArr\":[\"https://jdc.jd.com/img/1125x165?fs=60&t=楼层图片标题\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc17d9112f16cde9ee7edbc\",\"img0bannerId\":\"\"},\"protoProps\":{},\"mockProps\":{},\"colorProps\":[\"titleColor:9\",\"subTitleColor:9\",\"extraColor:9\"],\"comGroupTitle\":\"楼层标题\",\"comCateTitle\":\"全局\",\"id\":2,\"compId\":\"5c9c823f087e3f003f0f949a\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9c823f087e3f003f0f949a1557851692357.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9c823f087e3f003f0f949a1557851692357.js\",\"compName\":\"TitleFloor\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186016092,\"uuid\":1556186016092,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc17dd060b417b5bd656249\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/38810/16/2694/167936/5cc18501Eb2b5e4d6/b74e444a040830eb.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":3,\"k\":3,\"showLingTemplate\":false,\"scene\":\"通栏_1556186016092\",\"LingBnIdArr\":[{\"tplId\":\"5cc17dd060b417b5bd656249\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc17dd060b417b5bd656249\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"广告\",\"id\":3,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186027993,\"uuid\":1556186027993,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc17e8812f16cde9ee7edf3\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/33217/25/7341/199162/5cc18527Ee1d3c744/1d04452750e2a16b.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":4,\"k\":4,\"showLingTemplate\":false,\"scene\":\"通栏_1556186027993\",\"LingBnIdArr\":[{\"tplId\":\"5cc17e8812f16cde9ee7edf3\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc17e8812f16cde9ee7edf3\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"广告\",\"id\":4,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186033511,\"uuid\":1556186033511,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc17e0b4c7d92c478d17c9a\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/37668/33/5398/165024/5cc18540Ed7ddcc46/a0f64034313530ab.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":5,\"k\":5,\"showLingTemplate\":false,\"scene\":\"通栏_1556186033511\",\"LingBnIdArr\":[{\"tplId\":\"5cc17e0b4c7d92c478d17c9a\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc17e0b4c7d92c478d17c9a\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"广告\",\"id\":5,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9c823f087e3f003f0f949a1557851692357\",\"title\":\"图片标题\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b9b6054d4e9ba41f11c0fd7.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b9b6054d4e9ba41f11c0fd7.png\",\"props\":{\"data-fkey\":1556186046451,\"uuid\":1556186046451,\"layoutType\":\"img\",\"title\":\"图片标题\",\"titleColor\":\"#333333\",\"titleIcon\":\"\",\"subtitle\":\"\",\"subtitleColor\":\"#666666\",\"titlePosition\":\"center\",\"bgColor\":\"#ffffff\",\"showExtra\":false,\"extraColor\":\"#999999\",\"extraType\":\"1\",\"extraContent\":\"\",\"bgImg\":[{\"url\":\"无须录入链接\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/42405/4/328/14373/5cc18494E5253a68d/3954e231cb3dff2b.png\",\"tplid\":\"5cc18242bafe496e5fd85070\"}],\"key\":6,\"k\":6,\"showLingTemplate\":false,\"scene\":\"图片标题_1556186046451\",\"LingBnIdArr\":[{\"tplId\":\"5cc18242bafe496e5fd85070\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"bgImg\"}],\"defaultPicArr\":[\"https://jdc.jd.com/img/1125x165?fs=60&t=楼层图片标题\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18242bafe496e5fd85070\",\"img0bannerId\":\"\"},\"protoProps\":{},\"mockProps\":{},\"colorProps\":[\"titleColor:9\",\"subTitleColor:9\",\"extraColor:9\"],\"comGroupTitle\":\"楼层标题\",\"comCateTitle\":\"全局\",\"id\":6,\"compId\":\"5c9c823f087e3f003f0f949a\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9c823f087e3f003f0f949a1557851692357.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9c823f087e3f003f0f949a1557851692357.js\",\"compName\":\"TitleFloor\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186108450,\"uuid\":1556186108450,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc18219bafe496e5fd85063\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/44332/38/337/143008/5cc1844dE8595b3cd/59c5a0fd4e18693b.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":7,\"k\":7,\"showLingTemplate\":false,\"scene\":\"通栏_1556186108450\",\"LingBnIdArr\":[{\"tplId\":\"5cc18219bafe496e5fd85063\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18219bafe496e5fd85063\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":7,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186118154,\"uuid\":1556186118154,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc18219bafe496e5fd85063\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/31245/18/15276/143008/5cc18454E7785f2eb/bc75462ef2eca8f7.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":8,\"k\":8,\"showLingTemplate\":false,\"scene\":\"通栏_1556186118154\",\"LingBnIdArr\":[{\"tplId\":\"5cc18219bafe496e5fd85063\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18219bafe496e5fd85063\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":8,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186219972,\"uuid\":1556186219972,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc18219bafe496e5fd85063\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/31245/18/15276/143008/5cc18454E7785f2eb/bc75462ef2eca8f7.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":9,\"k\":9,\"showLingTemplate\":false,\"scene\":\"通栏_1556186219972\",\"LingBnIdArr\":[{\"tplId\":\"5cc18219bafe496e5fd85063\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18219bafe496e5fd85063\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":9,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186212223,\"uuid\":1556186212223,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc18219bafe496e5fd85063\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/31245/18/15276/143008/5cc18454E7785f2eb/bc75462ef2eca8f7.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":10,\"k\":10,\"showLingTemplate\":false,\"scene\":\"通栏_1556186212223\",\"LingBnIdArr\":[{\"tplId\":\"5cc18219bafe496e5fd85063\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18219bafe496e5fd85063\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":10,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186211198,\"uuid\":1556186211198,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc18219bafe496e5fd85063\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/31245/18/15276/143008/5cc18454E7785f2eb/bc75462ef2eca8f7.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":11,\"k\":11,\"showLingTemplate\":false,\"scene\":\"通栏_1556186211198\",\"LingBnIdArr\":[{\"tplId\":\"5cc18219bafe496e5fd85063\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18219bafe496e5fd85063\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":11,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9a2e3e6c75970047fbe76d1557851358817\",\"title\":\"通栏\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968dac93138d698c98d5d2.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968dac93138d698c98d5d2.png\",\"props\":{\"data-fkey\":1556186209983,\"uuid\":1556186209983,\"layoutType\":\"col1\",\"groupId\":\"01095010\",\"lingData\":[{\"tplid\":\"5cc18219bafe496e5fd85063\",\"url\":\"\",\"img\":\"//img10.360buyimg.com/ling/jfs/t1/31245/18/15276/143008/5cc18454E7785f2eb/bc75462ef2eca8f7.png\"}],\"adNum\":1,\"dataUrl\":\"http://api.mockon.jd.com/mock/bW9ja29uX2Jhc2U2NF9zYWx0Njk5\",\"allowScroll\":false,\"showSpacing\":false,\"showPadding\":false,\"key\":12,\"k\":12,\"showLingTemplate\":false,\"scene\":\"通栏_1556186209983\",\"LingBnIdArr\":[{\"tplId\":\"5cc18219bafe496e5fd85063\",\"bannerId\":\"\",\"comKey\":\"img\",\"parentKey\":\"lingData\"}],\"defaultPicArr\":[\"//jdc.jd.com/img/1125x500?t=图片尺寸1125*<=1500PX\"],\"hasPicArr\":true,\"img0LingTemId\":\"5cc18219bafe496e5fd85063\",\"img0bannerId\":\"\",\"dsType\":\"local\"},\"protoProps\":{\"groupId\":\"\",\"dsType\":\"ace\"},\"mockProps\":{\"groupId\":\"01095010\",\"dsType\":\"ace\"},\"isIsolate\":true,\"comGroupTitle\":\"基础广告\",\"comCateTitle\":\"常用\",\"id\":12,\"compId\":\"5c9a2e3e6c75970047fbe76d\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9a2e3e6c75970047fbe76d1557851358817.js\",\"compName\":\"AdBase\"},{\"type\":\"lc5c9c823f087e3f003f0f94781557851415081\",\"title\":\"楼层间隔\",\"icon\":\"//storage.jd.com/lcstatic/icon/5b968c7793138d698c98d5c8.svg\",\"cover\":\"//storage.jd.com/lcstatic/proto/5b968c7793138d698c98d5c8.png\",\"props\":{\"data-fkey\":1556186448935,\"uuid\":1556186448935,\"height\":\"30px\",\"bgColor\":\"rgba(254,229,63,1)\",\"key\":13,\"k\":13,\"showLingTemplate\":false,\"scene\":\"楼层间隔_1556186448935\"},\"protoProps\":{},\"mockProps\":{},\"isIsolate\":true,\"comGroupTitle\":\"楼层间隔\",\"comCateTitle\":\"全局\",\"id\":13,\"compId\":\"5c9c823f087e3f003f0f9478\",\"componentType\":\"m\",\"npmBundle\":\"//storage.jd.com/lccomponents/lc5c9c823f087e3f003f0f94781557851415081.tgz\",\"reactBundle\":\"//storage.jd.com/lccomponents/lc5c9c823f087e3f003f0f94781557851415081.js\",\"compName\":\"GapBase\"}],\"props\":{\"style\":{\"backgroundColor\":\"#fee53f\"},\"key\":0,\"k\":0,\"showLingTemplate\":false,\"scene\":\"页面容器_undefined\"},\"id\":0}]" subst = "img12.360buyimg" # You can manually specify the number of replacements by changing the 4th argument result = re.sub(regex, subst, test_str, 0) if result: print (result) # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html