Questions about Greps and FindChangeByList

Explorer ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

I'm willing to write a grep code to find my desired words. I'm looking for the word X that there are one or more kinds of spaces before it, or the word X is at the beginning of a paragraph. So far, I wrote this grep code:

([~|~< ]{1,}X)


The problem is I cannot add the ^ --that indicates the beginning of a paragraph to my grep code.
Since I'm writing a grep code, so I cannot add the WholeWord scope to my search, therefore, I wrote {1,} in my code.

TOPICS
Scripting

Views

131

Likes

Translate

Translate

Report

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

Adobe Community Professional , Jun 26, 2022 Jun 26, 2022
Hi @SunFlower16, if you are using Find Grep (not ExtendScript) you can use something like ^\s*\K\w+ to find the first word in a paragraph, even if there are spaces before it. Or a specific word "Word": ^\s*\KWord - Mark

Likes

Translate

Translate
Adobe Community Professional , Jun 26, 2022 Jun 26, 2022
In that case you should be able to use either \<X\> or \bX\b - Mark 

Likes

Translate

Translate
Adobe Community Professional ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

Hi @SunFlower16, if you are using Find Grep (not ExtendScript) you can use something like

^\s*\K\w+

to find the first word in a paragraph, even if there are spaces before it. Or a specific word "Word":

^\s*\KWord

- Mark

Likes

Translate

Translate

Report

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
Explorer ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

Thanks dear Mark.
Your grep code works properly, but it only has one part of my desired function. I'm willing to find the word X whether it is at the beginning of the paragraph or in the middle of a text. Let me clarify

X is a sample sentence.
is X a sample sentence.

 In both above sentences, I want to find the word X. Your grep code however only finds the X in the first sentence, not the second sentence.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

In that case you should be able to use either

\<X\>

or

\bX\b

- Mark 

Likes

Translate

Translate

Report

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
Explorer ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

I've got another question about FindChangeByList. I want to apply the No Break words, preferably without creating a No Break Character Style prior to applying the change. To elaborate I'm attaching what I want:
Screen Shot 2022-06-27 at 12.11.31.png
I want to find the words X[space]Y and apply No Break to the words X[space]Y. How can I write this on FindChangeByList?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

LATEST

Hi Brad, the symbol for a non-breaking space in Indesign's grep is ~S, so

FindWhat: X\sY
ChangeTo: X~SY

 - Mark

Likes

Translate

Translate

Report

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