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

How to select next line of text, using GREP?

Explorer ,
Apr 03, 2020 Apr 03, 2020

I use grep to search for linked images (~ a) and change the properties on that line, but I want to modify the text properties of the next line (the one highlighted in yellow) or in any case select the first word of the following line.

Thanks in advance.

Captura.JPG

Carpe diem
TOPICS
How to , Scripting , Type
2.2K
Translate
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

Guide , Apr 03, 2020 Apr 03, 2020

Hi Brian!  😉

 

Change:

 

 

myFinds[i].paragraphs[0].lines[1].leading = 20;

 

 

by:

 

 

myFinds[i].lines[0].insertionPoints[-1].lines[0].leading = 20;

 

 

or, less greedy (only the first char of the next line):

 

myFinds[i].lines[0].insertionPoints[-1].lines[0].characters[0].leading = 20;

 

 

(^/) The Jedi 

Translate
Community Expert ,
Apr 03, 2020 Apr 03, 2020

Use for those paragraphs a style which has not a fixed value, use (auto).

Translate
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 ,
Apr 03, 2020 Apr 03, 2020

Do you have a visible example of what you are saying?

Carpe diem
Translate
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 ,
Apr 03, 2020 Apr 03, 2020

Change the leading to (auto) in that paragraph style. Instead of something like 12 pt without paranthesis.

auto.png

Translate
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 ,
Apr 03, 2020 Apr 03, 2020

I want to edit the following line with parameters that I have in my script, I just need to select it. Same thanks for trying to give a solution, but it is not what I need.

Carpe diem
Translate
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 ,
Apr 03, 2020 Apr 03, 2020

Do you expect the next line to always be the second line in the containing paragraph? If so, you can try looping through your finds like this: 

 

 

for (var i = 0; i < myFinds.length; i++) {
    $.writeln(myFinds[i].parent.paragraphs[0].lines[1].contents);
}

 

If you want the first word, you would append words[0] after lines[1]

 

Translate
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 ,
Apr 03, 2020 Apr 03, 2020
//CLEAN GREP
app.findGrepPreferences = null;
app.changeGrepPreferences = null;


//find image and replace property of text  :
app.findGrepPreferences.findWhat="~a";
app.changeGrepPreferences.leading = 20; //INTERLINEADO
app.changeGrepPreferences.baselineShift  = -10;//DEZPLAZAMIENTO VERTICAL

app.changeGrep(true);


// find image and select next line 


app.findGrepPreferences = null;
app.changeGrepPreferences = null;

//what grep do i use here?

app.changeGrepPreferences.leading = 20; //INTERLINEADO
app.changeGrep(true);
Carpe diem
Translate
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 ,
Apr 03, 2020 Apr 03, 2020

Easier to just do this rather than rely solely on GREP. 

app.findGrep returns an array of Character that you can then loop through to find containing paragraph and execute on the lines.  

 

 

 

 

//CLEAN GREP
app.findGrepPreferences = null;
app.changeGrepPreferences = null;

//GET FIND GREP
app.findGrepPreferences.findWhat="~a";
var myFinds = app.findGrep(true);

for (var i = 0; i < myFinds.length; i++) {
    try {
       myFinds[i].leading = 20;
       myFinds[i].baselineShift = -10;
       myFinds[i].paragraphs[0].lines[1].leading = 20;
   } catch(e) {
      continue;
   }
}

app.findGrepPreferences = null;
app.changeGrepPreferences = null;

 

 

 

 

Translate
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
Guide ,
Apr 03, 2020 Apr 03, 2020

Hi Brian!  😉

 

Change:

 

 

myFinds[i].paragraphs[0].lines[1].leading = 20;

 

 

by:

 

 

myFinds[i].lines[0].insertionPoints[-1].lines[0].leading = 20;

 

 

or, less greedy (only the first char of the next line):

 

myFinds[i].lines[0].insertionPoints[-1].lines[0].characters[0].leading = 20;

 

 

(^/) The Jedi 

Translate
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 ,
Apr 03, 2020 Apr 03, 2020

Better, sure! 

Translate
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 ,
Apr 03, 2020 Apr 03, 2020

Michel__FRIdNGE_ a query, from my GREP search, how can I get the path of these linked images?

Carpe diem
Translate
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 ,
Apr 03, 2020 Apr 03, 2020
LATEST
myFinds[i].pageItems[0].graphics[0].itemLink.filePath;
Translate
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