Chat now with support
Chat with Support

LiteSpeed for SQL Server 8.5 - Configure Log Shipping Guide

Use Wildcard and Regular Expressions in LiteSpeed

Use Wildcard and Regular Expressions in LiteSpeed

You can configure LiteSpeed to only back up databases that match the specified pattern. Using wildcard and regular expressions is particularly helpful when there are databases with similar names on the same instance or on multiple instances.

Tips:

  • To back up databases with similar names on multiple instances, create and deploy a backup template, or create a maintenance plan on one instance and then simply copy it to other instances.
  • LiteSpeed lets you enter multiple patterns. When selecting databases for your maintenance plan, you can click Validate selected or Validate all to display a list of databases names that match any of the specified patterns.

Wildcard Expressions

You can use wildcard characters '?' and '*' to select databases you want to back up. For example, "litespeed*" will include all databases that start with "litespeed" or "LiteSpeed".

Regular Expressions

Using regular expressions can provide you with more flexibility when selecting databases. For example, the following expressions will include a database if its name:

  1. Begins with "LiteSpeed".

    ^LiteSpeed

  2. Ends with "_PUBLISHER".

    _PUBLISHER$

  3. Begins with "LiteSpeed" followed by digits.

    ^LiteSpeed\d+

  4. Contains any number within the range 828500 to 828549.

    8285[0-4][0-9]

  5. Begins with "LiteSpeed" or "Quest", except "QuestSoftwareCMSS".

    ^(?!QuestSoftwareCMSS)(Quest|LiteSpeed)

NOTES:

  • Regular expressions are only supported in Maintenance Plans.
  • LiteSpeed does not support regular expressions with the IgnoreCase option. To ignore case, use ([Aa][Bb][Cc]) instead of (?i:abc).

Review the following for additional information:

Construct Description
^

The character following this construct is at the beginning of the document or new line.

Text: no cat can catch a crow

Expression: ^\w+

Matches: no

$

The character followed by this construct is at the end of the string.

Text: no cat can catch a crow

Expression: \w+$

Matches: crow

(normal characters)

Characters match themselves, except for the following: ^ . * + ? { [ ( | ) \ $

\

The character immediately following it, when that character is not an escaped character.

Expression: \*

Matches: *

\w

Any word character (A - Z and a - z), digits, and underscores.

Text: no cat can catch a crow

Expression: ca\w+

Matches: cat, can, catch

\W

Any non-word character.

Text: 9pm @ RockCafe

Expression: \W

Matches: @

\d

Any digit.

Text: APR-2012

Expression: \d\d\d\d

Matches: 2012

\D

Any non-digit.

Text: APR-2012

Expression: \D\D\D

Matches: APR

\s

Any whitespace character.

Text: no cat can catch a crow

Expression: c\w\w\s

Matches: "cat " and "can "(both matches include the space)

\S

Any non-whitespace character.

Text: no cat can catch a crow

Expression: c\S+

Matches: cat, can, catch, crow

[ ]

Any character within the brackets.

Expression: p[ai]ck

Matches: pick, pack

[ - ]

Any character within the specified range. [0-9a-fA-F] matches a single hexadecimal digit, without case sensitivity.

Expression: b[a-z]ttle

Matches: battle, bottle

NOTE: The - character is considered a literal character if it used as the first or last character within the brackets, or if it is escaped with a backslash.

[^ ]

Any character that is not in the specified set of characters.

Expression: d[^u]g

Matches: dog and dig but not dug

.

Any single character. When preceded with the escape character (\), it is equivalent to a period character.

Expression: d.g

Matches: dog, dig, and dug

*

Zero or more matches of the preceding character.

Expression: a*ha

Matches: ha, aha, aaha, aaaha, etc.

?

Zero or one matches of the preceding character.

Expression: colou?r 

Matches: color and colour

+

One or more matches of the preceding character.

Expression: goo+gle

Matches: google, gooogle, etc.

{n}

The exact number of matches for the preceding character.

Text: he had to go too far

Expression: o{2}

Matches: oo in "too"

{n,m}

The preceding character must match at least "n" times but no more than "m" times.

Expression: mo{2,3}n

Matches: moon and mooon, but not mon or moooon

( )

Matches subexpression.

|

Matches any of the alternate expressions.

Expression: theat(er|re)

Matches: theater and theatre

(?# )

A comment within a regular expression. The comment ends after the first closing parenthesis.

Expression: theat(er|re)(?# using this example a second time)

Matches: theater and theatre

(?= )

A zero-width positive lookahead assertion.

Expression: ^(?=.{32}$)(\d+)

Matches: numbers at the beginning of any line which is exactly 32 characters long

(?! )

A zero-width negative lookahead assertion.

Expression: ^(?!test).+

Matches: any line that does not begin with "test"

For more information about regular expressions, see

Related Documents