Hello visitor! A note about the contents of this wiki: Barotrauma is a game with several years' worth history as a free-download open source game, and this wiki has been written primarily based on this legacy version. As such, not all content is relevant to the Steam release. So please wait patiently as the contents are updated, and feel free to contribute new information once the Steam version of Barotrauma is released!

Guide to Regular Expressions

From Barotrauma Wiki
Jump to: navigation, search

All classes are case sensitive.

Link to Unicode "Basic Latin (0000-007F)" reference sheet: https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)

Link to RegExr: https://regexr.com/

RegEx Find Component
RegEx Component.png
Stats
Type Electrical Component
Item Cost 10 Marks
Skill Requirements
Crafting
Constructible? Checkmark True.png
Deconstructible? Checkmark True.png

Character Classes[edit | edit source]

Character Set - [ABC][edit | edit source]

Matches any character in the set.

Ex. [abcd] - "The quick brown fox jumps over the lazy dog." 0123456789

Negated Set - [^ABC][edit | edit source]

Matches any character not in the set.

Ex. [abcd] - "The quick brown fox jumps over the lazy dog." 0123456789

Range - [A-Z][edit | edit source]

Matches any character with a character code between the two specified characters.

Ex. [0-a] - "The quick brown fox jumps over the lazy dog." 0123456789

Dot - .[edit | edit source]

Matches any character.

Ex. . - "The quick brown fox jumps over the lazy dog." 0123456789

Word - \w[edit | edit source]

Matches any alphanumeric characters, along with underscore.

Ex. \w - "The quick brown fox jumps over the lazy dog." 0123456789

Not Word - \W[edit | edit source]

Matches any character that is not alphanumeric or underscore.

Ex. \W - "The quick brown fox jumps over the lazy dog." 0123456789

Digit - \d[edit | edit source]

Matches any number.

Ex. \d - "The quick brown fox jumps over the lazy dog." 0123456789

Not Digit - \D[edit | edit source]

Matches any character that is not a number.

Ex. \D - "The quick brown fox jumps over the lazy dog." 0123456789

Whitespace - \s[edit | edit source]

Matches any whitespace character, such as space or tab

Ex. \s - "The quick brown fox jumps over the lazy dog." 0123456789

Not Whitespace - \S[edit | edit source]

Matches any non-whitespace character.

Ex. \S - "The quick brown fox jumps over the lazy dog." 0123456789

Ex. \S - "The quick brown fox jumps over the lazy dog." 0123456789

Anchors[edit | edit source]

Beginning - ^[edit | edit source]

Matches the beginning of a string.

Ex. ^Test - Test Test

End - $[edit | edit source]

Matches the end of a string.

Ex. $TesT - TesT TesT

Word Boundary - \b[edit | edit source]

Matches a character between a word character and non-word character or position. (see Word)

Ex. T\b - TesT TesT

Not Word Boundary - \B[edit | edit source]

Matches any position that is not a word boundary.

Ex. T\B - TesT TesT

Quantifiers[edit | edit source]

Plus - +[edit | edit source]

Matches 1 or more of the preceding token.

Ex. meow\w+ - meow meowing meowed meows homeowner

Star - *[edit | edit source]

Matches 0 or more of the preceding token.

Ex. meow\w* - meow meowing meowed meows homeowner

Quantifier - {3, 5}[edit | edit source]

Matches the specified quantity of the previous token.

Ex. meow\w{3,5} - meow meowing meowed meows homeowner

Optional - ?[edit | edit source]

Matches 0 or 1 of the preceding token.

Ex. meow\w? - meow meowing meowed meows homeowner

Alternation - |[edit | edit source]

Matches the expression before or after the vertical bar.

Ex. (fox)|(dog) - "The quick brown fox jumps over the lazy dog." 0123456789

Tips & Tricks[edit | edit source]

  1. You can put a backslash \ before a special character +*?^$\.[]{}()|/ to represent a literal character.
  2. You can place parentheses () around 1 or more tokens/quantifiers to create a capture group.