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

GREP code

Explorer ,
Mar 25, 2017 Mar 25, 2017

Copy link to clipboard

Copied

Hello

Are there any GREP code find words located at the beginning of baselines ( at the beginning of lines not the beginning of paragraph ) .

123.png

Views

1.4K

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

Explorer , Mar 26, 2017 Mar 26, 2017

Thank you

Votes

Translate

Translate
Community Expert ,
Mar 26, 2017 Mar 26, 2017

Copy link to clipboard

Copied

No. GREP is not aware of individual lines.

To do something with lines, you need a script.

Votes

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 ,
Mar 26, 2017 Mar 26, 2017

Copy link to clipboard

Copied

Thank you

Votes

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
LEGEND ,
Mar 26, 2017 Mar 26, 2017

Copy link to clipboard

Copied

Hi,

Only by curiosity, what do you wanna do?

(^/)

Votes

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
LEGEND ,
Mar 26, 2017 Mar 26, 2017

Copy link to clipboard

Copied

Aha! Now moderators can mark as correct all marks of politeness! Cool!

… [just immediately for comment and explanations later] It can be done with Grep, without script, in 1 click!

Of course, hyphenation prohibited! 

Capture d’écran 2017-03-26 à 15.02.34.png

(^/) 

Votes

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 ,
Mar 26, 2017 Mar 26, 2017

Copy link to clipboard

Copied

Hi

This is example : i want the GREP to find the word ( بن ) in this Arabic text if this word located at the beginning of line ( not beginning of paragraph )>>>> them i may replace the text or apply a character style on it ...  :

123456.png

I know how to make a word boundary in GREP but i do not find GREP code to find this word at the beginning of lines .

I know  that : script can do this but , are there GREP code to do this .

Votes

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
Community Expert ,
Mar 26, 2017 Mar 26, 2017

Copy link to clipboard

Copied

I would use Find Text not GREP in this case to find بن where ever it may be, and apply a character style right from the Change format section.

Screen-Shot-2017-03-27-at-9.21.01-AM.jpg

Votes

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 ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Hi

But i want to change word ( بن ) only if it's at the beginning of line ....

Votes

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
LEGEND ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

… So, let's go! 

Deal:

Let's find my name "Obi-wan Kenobi" [ "Ben", for friends! … ] ONLY if at the beginning of a line and let's apply "Obi-wan Kenobi CharStyle" to it!

As I said [post#4] … with Grep, without script and in 1 click! 

Capture d’écran 2017-03-27 à 15.51.35.png

In the text, we have 8 mentions! To make it more visible for you, I've applied to my name a condition "Obi-wan Kenobi Condition" (blue underlining).

Capture d’écran 2017-03-27 à 15.52.10.png

… But we only want the 4 ones on the left side!

To play this game, we need to play with "lines"!

I totally agree with Jongware! It's not the play area of Grep! … But, all kids love to play in sandboxes! 

The trick is to "get lines"!

Capture d’écran 2017-03-27 à 15.52.43.png

Capture d’écran 2017-03-27 à 15.57.48.png

… So, just 2 simple regex:

Capture d’écran 2017-03-27 à 16.08.43.png

Capture d’écran 2017-03-27 à 16.08.24.png

And a Multi-Find/change* set:

Capture d’écran 2017-03-27 à 16.07.13.png

[ * Great thanks to our friend Martinho da Gloria for this awesome plugin!  ]

Done!

Capture d’écran 2017-03-27 à 16.08.04.png

(^/)

Votes

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
Community Expert ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Amazing Obi-wan, a real Jedi master you are!

Votes

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
LEGEND ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Pour les "grognons"! 

app.findGrepPreferences = app.changeGrepPreferences = null;   

app.findGrepPreferences.findWhat = "Obi-wan Kenobi";

myFound = app.activeDocument.findGrep();

var F = myFound.length,  s = String("Obi-wan Kenobi").length;

for ( var f = 0; f < F; f++ )  if ( myFound.contents == myFound.lines[0].characters.itemByRange(0, s-1).contents )  myFound.appliedCharacterStyle = "Obi-wan Kenobi CharStyle";

app.findGrepPreferences = null;

Version courte !

(^/)

Votes

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
LEGEND ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

LATEST

Pour les "très-grognons, qui chercheraient seulement le premier mot de chaque ligne"! 

var myWords = app.activeDocument.stories.everyItem().paragraphs.everyItem().lines.everyItem().words[0].getElements(),  W = myWords.length;

for ( var w = 0; w < W; w++ ) myWords.appliedCharacterStyle = "Red";

Version bikini !

(^/)

Votes

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