Regular Expressions in Google Docs

Expression Description Example string in  Find box Examples from document Matches
. This will highlight strings of text that match what is typed in the Find text box if there is one letter after the string. me.
  • came
  • mental
  • premeditated
  • made
  • manufactured
  • mental
  • premeditated

*These strings were highlighted because there is a character after the characters in the Find box.

Came was not because there was not a character after me. Manufactured doesn’t have an me in it.

* An asterisk after a character will allow for the matching characters in the document to be highlighted and words that have one less character in the string. me*
  • came
  • mental
  • premeditated
  • made
  • elated
* The only string not highlighted is elated because it does not contain an m.
+ A plus after a character highlights for the string plus one character. me+
  • came
  • mental
  • premeditated
  • made
  • elated
  • came
  • mental
  • premeditated

*These words are highlighted because each one has a character after me.

? This will highlight strings of characters that match those in the Find box or have one more or one less character. med?
  • mental
  • made
  • med
  • me
  • medical
  • mental
  • med
  • me

*Made is the only string that is not highlighted. Med is highlighted because it matches the string exactly. Mental and Me are highlighted because they have me, one less character than med.Medical is highlighted because it has one more character than med.

{A, B} A and B represent the number of times a character in parentheses is repeated. Numbers will be used instead of A and B. fr(o{2,4})g
  • Frog
  • Froug
  • Froogle
  • Frooog
  • Fro
  • Frodo
  • Froogle
  • Frooog

* Froogle has two Os, which is equal to the number that is in the A position.

Frooog has three Os, so it was highlighted because it has one less than what is in the B position.

[x], [xa], [xa5] A character set indicates that just one of the given character(s) should occur in the current position. Usually, any characters are valid within brackets, including characters mentioned previously in expressions: [xa,$5Gg.]. fro[au]g
  • Frog
  • Froug
  • Froogle
  • Frooog
  • Fro
  • Frodo
  • Froagle
  • Froug
  • Froagle

* Froug is highlighted because it has a u.

Froagle is highlighted because it has an a.

[a-z] A character set range signifies a search for a character within the given range of characters. Ranges can be combined into a single range: [a-zA-Z0-9]. Ranges can also be combined with character sets (mentioned previously): [a-zA-Z,&*]. fro[n-z4-8]g
  • Frog
  • Froug
  • Froogle
  • Frooog
  • Fro6gle
  • Froug
  • Froogle
  • Fro6gle

* Froug and Froogle are selected because the have letters between n-z range.

Fro6gle is highlighted because the range falls between 4-8.

[^a-fDEF] A character set beginning with a ^ signifies a search for a character that is not within the given set. [^fro]og
  • Dog
  • Hog
  • Frog
  • Froug
  • Froogle
  • Dog
  • Hog

* These two words are highlighted because they don’t start with f or g.

\s Any white-space character. d\sg
  • Froagle
  • D og
  • D g
  • D[TAB]g
  • D g
  • D[TAB]g

*These two strings of text have a space between the d and g, without any other characters between them.

 

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close