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 ) .
Thank you
Copy link to clipboard
Copied
No. GREP is not aware of individual lines.
To do something with lines, you need a script.
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
Hi,
Only by curiosity, what do you wanna do?
(^/)
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!
(^/)
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 ... :
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 .
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.
Copy link to clipboard
Copied
Hi
But i want to change word ( بن ) only if it's at the beginning of line ....
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!
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).
… 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"!
… So, just 2 simple regex:
And a Multi-Find/change* set:
[ * Great thanks to our friend Martinho da Gloria for this awesome plugin! ]
Done!
(^/)
Copy link to clipboard
Copied
Amazing Obi-wan, a real Jedi master you are!
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 !
(^/)
Copy link to clipboard
Copied
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 !
(^/)