Skip to main content
dublove
Legend
May 23, 2025
Answered

What is the difference between \b and \< \>?

  • May 23, 2025
  • 1 reply
  • 582 views

It seems like you can't tell the difference in general.
Once I found the difference, it seems that one contains boundaries while the other only contains in-bounds.
I can't find an obvious example.

Correct answer dublove

Maybe a language thing - I'm not saying you'll get the same results - I'm showing the differences the searches can make and how 1 or the other can show different results. 

 

Maybe rules are different in different languages.


I seem to know roughly the difference between \< \> and \b.
\< \> is bounded by (but not including) the punctuation or \s.
\b is bounded by the left and right of the punctuation or \s.

Use these two to see the difference:
(? <=\<). +? (? =\>)
(? <=\b). +? (? (=\b)
There is no difference in general use.

1 reply

Community Expert
May 23, 2025

In InDesign GREP, \b means a word boundary. It matches places where a word starts or ends, but it's quite picky. It only sees letters, numbers and underscores as part of a word. So if you search for \bword\b, it will find the word "word" by itself, but not "word1" or "word-2", because those are seen as longer or different words.

 

\< means the start of a word and \> means the end of a word. These two are more flexible. \<word will find "word", "word1", "word-2", even "word_3". It just cares that the word starts with "word".

 

And if you pair them up like \<word.+?\>, it’ll find the full stretch of text starting with "word" and ending at the edge of the word, even if it’s got dashes, numbers or underscores in it.

 

So, if you’re trying to match full words that start with "word", go with \< and \>. If you only want the pure word "word" with nothing stuck to it, go with \b.

 

Simple rule

Use \b when you want the exact word.

Use \< and \> when you want the start and end of bigger words.

 

dublove
dubloveAuthor
Legend
May 23, 2025

It doesn't seem all right.
In general there is no difference between \bword\b and \<word\>.
\<word also can't match word2

Community Expert
May 23, 2025

Here's a visual for you 

 

So \bword\ only cares about 'word' 

\<word\> cares about the entire text beyond words 

 

\b specifies a boundary 

\< \> specifies location - it's a bit greedy because I haven't specified -1 or _2 but because it starts with word it's including everything from beginning of word up to the end of the word - as it sees - and _ as part of the word.

 

\b doesn't