简体   繁体   中英

Ways to do RegEx matching for *|TAG_NAME|*

I have an edm template input/generated by a web frontend, and I have to replace all merge tags in the format *|TAG_NAME|* with its corresponding value.

I tried to use the below RegEx but it seems I got an error on the | characters.

^\*|[0-9A-Za-z]+|\*$

Below is a sample template (in json format):

"fields": [
  {
    "key": "member_id",
    "label": "Member ID",
    "value": "*|member_id|*"
  }

Any help is appreciated!

| is a special regex metacharacter (means OR), therefore you have to escape it with \\

^\*\|[0-9A-Za-z]+\|\*$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM