Skip to main content
johnf35366569
Inspiring
February 7, 2024
Answered

Grep style formula needed

  • February 7, 2024
  • 2 replies
  • 695 views

Looking for a no break GREP style to keep '(Graph 2.10)' from breaking. The Graph reference will change throughout so need a wild card for the number if that makes sense. so the next could be 2.11 etc.

Thanks

 

 

 

This topic has been closed for replies.
Correct answer Eugene Tyson

although that can find words probably like

telegraph 230

paragraph 2

 

so you could clarify with word boundary

 

(?i)\bgraph\b\K

 

probably does it - sorry I can't test right now.

2 replies

Inspiring
February 7, 2024

Find what in Grep:

(g|Graph)( )(\d.\d+)

Changed To

$1~S$3

Community Expert
February 7, 2024

That's cool - but it's a find/change - they are looking for a Style

So you need to look around the space and isolate the space

 

But it is another way if they are happy with find change

I think your search would find telegraph 1, or paragraph 6, or spectrograph 1 etc. 

And the \d.\d+ only finds one digit

so it wouldn't find 20.1

it would find 20 ( \d . (digit + wildcard) ) 

it would need to be \d+\.\d+

but this wouldn't include 20.3.4 so might not get all

 

 

Inspiring
February 7, 2024

I didn't test earlier but you can try now:

\<([gG]raph)( )(?=\d)

changed to 

$1~S

 

 

Community Expert
February 7, 2024

Create a blank character style called 'No Break'

 

in the paragraph style go to the Grep Style section (call it Graph No Break or something you'll remember)

 

Set the Character Style you just created

(?i)graph\K\h(?=\d)

 

This finds any variation of graph Graph GRAPH etc. with (?i)

\K tells it to ignore this part 

\h is any horizontal space

(?=) is a postive lookahed - it doesn't include it in the search

(?=\d) is telling it to lookahead for a digit but don't include it


Logically

So any thing that is graph with any combination of upper/lowercase

find the horizontal space

check ahead for a digit but don't include

apply the no break

 

so it won't matter if it's 2.10 or 210.0345

It will find a space between graph and a digit

graph 2.10

Graph 210.0345

GRAPH 2.10.213.34

 

it's just identifying the space.

Eugene TysonCommunity ExpertCorrect answer
Community Expert
February 7, 2024

although that can find words probably like

telegraph 230

paragraph 2

 

so you could clarify with word boundary

 

(?i)\bgraph\b\K

 

probably does it - sorry I can't test right now.