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

grep question, apply bold

Guru ,
Nov 05, 2018 Nov 05, 2018

Hi, i am trying to apply my BOLD character style to "Figure 1" in my copy. and i set the code to the below. as in apply bold to any word Figure and whatever number(s) is next to it. but this is not correct, what am i doing wrong?

Screen Shot 2018-11-05 at 8.30.47 AM.png

1.1K
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 1 Correct answer

Community Expert , Nov 05, 2018 Nov 05, 2018

(Table|Box|Figure)\s\d+

You need to put your three variations within parentheses, otherwise it will find just the word Table, just the word Box, or the word Figure followed by a space and one or more digits.

Translate
Community Expert ,
Nov 05, 2018 Nov 05, 2018

If you always have a space after the word Figure, then all you need is Figure \d+

But keep in mind that if you want your parentheses to also be bold, you will need \(Figure \d+\)

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 ,
Nov 05, 2018 Nov 05, 2018

No, your regex is incorrect. What you have written is: apply bold to the word Figure if it is followed by a digit (or more). Try this:

Figure\s\d+

It means the word Figure, followed by one space and one or more digits

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 ,
Nov 05, 2018 Nov 05, 2018

jmlevy  wrote

No, your regex is incorrect. What you have written is: apply bold to the word Figure if it is followed by a digit (or more).

Actually it's just "Figure" when followed by one of more plain d's (also without any space). So it'd match "Figured" and "Figureddd" but not "Figure 2" or "Figure2".

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
Guru ,
Nov 05, 2018 Nov 05, 2018

that did it.  so if i want to say to that however to also look for the word "Table" and "box" the code will be:

Table|Box|Figure\s\d+

correct? because "|" means "or"

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
Guru ,
Nov 05, 2018 Nov 05, 2018

just tried that last code and "Box" goes bold, but not the number next to it:

Screen Shot 2018-11-05 at 9.31.33 AM.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 ,
Nov 05, 2018 Nov 05, 2018

(Table|Box|Figure)\s\d+

You need to put your three variations within parentheses, otherwise it will find just the word Table, just the word Box, or the word Figure followed by a space and one or more digits.

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
Guru ,
Nov 05, 2018 Nov 05, 2018

BINGO!

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
Guru ,
Nov 05, 2018 Nov 05, 2018

how would you tackle adjusting that code if there is a letter instead of a number and if there was two letters, like the two below circumstances? i have "Figure 2A" and "Figure 2B-C"

Screen Shot 2018-11-05 at 10.06.29 AM.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 ,
Nov 05, 2018 Nov 05, 2018
LATEST

You can add the following to the existing code - it will catch these instances along with the plain number ones

\u?–?\u?

Your full code will look like this: 

(Table|Box|Figure)\s\d+\u?–?\u?

Just make sure that the dash or hyphen you use in the code is the same one that you used in your text. (In this usage, should be an n-dash)

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