Search text with regular expressions
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
The following regular expressions can replace characters or digits in the Find what field of the SQL Server Management Studio Find and Replace dialog box.
Search using regular expressions
To enable the use of regular expressions in the Find what field during Quick Find, Find in Files, Quick Replace, or Replace in Files operations, select the Use option under Find Options and then choose Use Regular Expressions.
The Expression Builder button next to the Find what field then becomes available. Select this button to display a list of the available regular expressions. When you choose any item from the Expression Builder, it is inserted into the Find what string.
The following table describes the regular expressions available in the Expression Builder.
Expression | Description |
---|---|
. |
Match any single character (except a line break) |
.* |
Match any character zero or more times |
.+ |
Match any character one or more times |
[abc] |
Match any character in the set abc |
[^abc] |
Match any character not in the set abc |
\d |
Match any numeric character |
(?([^\r\n])\s) |
Match any whitespace character |
\b |
Match at beginning or end of word |
^ |
Match at beginning of line |
.$ |
Match any line break |
\w\r?\n |
Match a word character at end of line |
(dog|cat) |
Capture and implicitly number the expression dog|cat |
(?<pet>dog|cat) |
Capture subexpression dog|cat and name it pet |
See also
Feedback
Submit and view feedback for