Regular Expressions 101

Community Patterns

Define and detect custom tag with specific prefix & suffix

1

Regular Expression
ECMAScript (JavaScript)

/
<:([^<:>\s]+?):>
/
gm

Description

Define and detect custom tag with specific prefix & suffix

  • Define custom tag : <:tag_name:> .
  • Regex is /<:([^<:>\s]+?):>/gm .
  • Prefix is <: .
  • Suffix is :> .
  • tag_name can not contain prefix, suffix, space, tab or newline character .
  • tag_name can not be null .
  • You can get tag_name string use $1 .
  • Prefix and suffix any unicode character , just use \uXXXX in regex.
Submitted by ShenTengTu - 7 years ago