Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Guide ,
May 22, 2025 May 22, 2025

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.

TOPICS
Bug , Feature request , How to
263
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 22, 2025 May 22, 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

...
Translate
Guide , May 26, 2025 May 26, 2025

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.

Translate
Community Expert ,
May 22, 2025 May 22, 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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 22, 2025 May 22, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2025 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

 

Screenshot 2025-05-23 at 09.08.56.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 23, 2025 May 23, 2025

Why am I getting such results?
Can you share your sample file?

006.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2025 May 23, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 23, 2025 May 23, 2025

Your explanation at the top is probably right.
A long time ago, I really saw the difference between them, but I can't give that example now.
It's depressing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 26, 2025 May 26, 2025
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines