Views

Regular Expressions

The Wiki of Unify contains information on clients and devices, communications systems and unified communications. - Unify GmbH & Co. KG is a Trademark Licensee of Siemens AG.

Revision as of 14:12, 29 January 2024 by Sven (talk | contribs) (Example Regular Expressions)
Jump to: navigation, search

Introduction

Regular expressions (often called regex or regexp) are powerful sequences of characters that define a search pattern. They're used for string matching within text, allowing you to search and match strings based on a specified pattern. A regular expression may contain literals or special characters with a predefined meaning.

Elements of a regular expression

  • Anchors: Assert the start and end position of a line. ^ (caret) matches the start and $ (dollar sign) matches the end.
  • Character class: Enclosed in square brackets [ ], defines a set of characters to match. For example, [aeiou] matches any vowel.
  • Capturing group: Parentheses ( ) are used to create groups, used to treat multiple characters or subpatterns as a single unit.
  • Quantifiers: Specify the number of occurrences of the preceding character, character class or group. Common quantifiers include * (zero or more), + (one or more), ? (zero or one), and {} (exact number or range).
  • Alternation: | (pipe). It allows you to specify alternatives, matching either the pattern on the left or the one on the right.
  • Negation: ^ (caret). Used inside a character class. Matches any character not listed in the character class. [^aeiou] matches any character that is not a vowel.
  • Escape character: \ (backslash). It is used to escape a special character, allowing you to match it as a literal. Also used for encoded characters, e.g. \x20 matches a white space character.

Examples

Some example regular expressions to be used within Openscape Endpoint Management.

IP address range

The following examples can be used for matching IP address ranges

192\.168\.0\.((2[5-9])|(3[0-9]))