use of colon symbol in regular expression

Colon : is simply colon. It means nothing, except special cases like, for example, clustering without capturing (also known as a non-capturing group):

(?:pattern)

Also it can be used in character classes, for example:

[[:upper:]]

However, in your case colon is just a colon.

Special characters used in your regex:

In character class [-+_~.\d\w]:

  • - means -
  • + means +
  • _ means _
  • ~ means ~
  • . means .
  • \d means any digit
  • \w means any word character

These symbols have this meaning because they are used in a symbol class [].
Without symbol class + and . have special meaning.

Other elements:

  • =? means = that can occur 0 or 1 times; in other words = that can occur or not, optional =.

Leave a Comment