Some Basic Regular Expression Search Examples

Search & Replace regex2 shg General Search Examples

Search & Replace relicon1 General Search Examples Also see

Some Basic Regular Expression Search Examples

What to Match

Operator

Examples

Any single character

?

g?t finds get, got, gut, together

Any string of characters (one or more)

+

w+e finds wide, white, write but not we

Any string of characters (or none)

*

w*e matches wide, white, write and we

One of the specified characters

[]

g[eo]t matches get and got but not gut

One of the characters in a range

[-]

[b-p]at matches bat, cat, fat, hat, mat but not rat or sat

All characters

[]

l[] matches line, list, late

One expression or another

(|)

W(elcome to|indows 2000) matches
Welcome to or Windows 2000

One or more expressions

+()

+(at) matches atat in catatonic and at in battle

All characters (perhaps on different lines)

*[]

h*[]d matches helped, Hello World, & Hello (cr lf) Win95 World. Use [] instead of complicated range expression such as [a-zA-Z0-9]. This will span across lines up to the limit set by Maximum Regular Expression Size (Search Options).

Two strings “nearby” (perhaps on different lines)

*[]

the*[-ÿ]first matches the first and the (cr lf) very first

Note: This is an older style syntax using Binary characters.

A string that doesn’t start with an expression

!()

*: !(http) finds : in following: but not in http://www.funduc.com

One of the characters not in a range

![-]

[a-z]at!([b-p]at) matches rat & sat but nothing in bat, cat, hat.

Note: Older syntax for this would be ![b-p]at

Find all words of length x

 

+x[a-z], e.g., +3[a-z] finds all 3 letter words.

Note: We previously supplied a ! operator example here. By way of example, to do this with a ! operator, the expression would be
?+3[a-z]?!(?[a-z]+3[a-z]?[a-z]). This would not be an efficient approach however.

An expression at the beginning of a line

^

^the finds the at the beginning of a line and The if case sensitive is turned off.

An expression at the end of a line

$

end$ finds end when it’s the last string on a line.

One or more column(s) before or after a string

+n

[h]+4// finds http:// but not https://

General Search Examples