Skip to main content
Participant
November 7, 2023
Question

grep - style for substring

  • November 7, 2023
  • 2 replies
  • 135 views
Hi,
I have text with the string ".-|"
I want to find the entire string, but use the style only for the first character "."
Adobe says - use cmd+f, type grep (.)(-|) and enter $1 in the >change to< field
but I want to use this grep in paragraph style - how to do it?
This topic has been closed for replies.

2 replies

Joel Cherney
Community Expert
Community Expert
November 8, 2023

In a paragraph style, you can only apply character styles with a GREP style. So, you'd have to find all full-stops followed by hyphen and pipe, but not include the hyphen and pipe, correct? 

 

The two easiest ways are:

1) Don't use a GREP Style, use a Nested Style instead. You can apply any character style Up To the first hyphen. This only works if you know that any fullstop followed by a hyphen should have the character style applied. If there are exceptions, this won't work. In which case, you can use...

 

2) Use a GREP Style with a positive lookahead. Your first group should be 

(\.)

 The backslash means "only match a fullstop character." If you don't escape your fullstop, it means "any one character" in GREP. Your second group should be 

(?=-|)

 This is a "positive lookahead" which means that it's going to match anything after the ?= but it's not included in what is found.  So it will look for 

.-|

but it is only going to match the period character, not the hyphen or pipe.  

Robert at ID-Tasker
Legend
November 7, 2023

Can you show a screenshot of a real text example?