9

Microsoft has a nifty quick reference card for .Net Regular Expressions.

But it seems to list \b as both matching Backspace and also matching "On word boundary".

Which is it? Can \b really do both? How can you be precise about which one you mean?

abelenky
  • 963
  • 2
  • 11
  • 23
  • 1
    I'm not sure why you asked a C#/.Net question here when you have 27k on Stack Overflow where this belongs, topically. – slhck Jun 20 '14 at 06:16
  • The Visual Studio IDE amd Powershell both use .Net expressions. I came across this question in the context of using the IDE. Searching and Editing files is more of a SuperUser task than a programming problem. – abelenky Jun 20 '14 at 09:04
  • I see, thanks. Maybe you can clarify the context, e.g. show a screenshot of the IDE or explain the searching files part? Then I'd say it's fine to stay here. – slhck Jun 20 '14 at 09:12

1 Answers1

8

\b means "word boundary" outside of character classes (also called character sets) and "backspace" inside character classes.

Here it means a word boundary:

\bhello\b

Here it means a backspace

[\b]

See this Microsoft reference: Character Escapes in Regular Expressions.
PERL regex has the same definition for \b.