Skip to main content
Inspiring
September 1, 2014
Question

How can Find minimum chars at the End of Paragraphs

  • September 1, 2014
  • 2 replies
  • 426 views

Hi,

How can find if minimum 4characters comes at the end of the paragraph.

Regards,

Vetha

This topic has been closed for replies.

2 replies

Chinnadk
Legend
September 2, 2014

Hi Vetha,

Is this you need?

var doc = app.activeDocument,

    _paragraphs = doc.stories.everyItem().paragraphs.everyItem().getElements();

 

for(var i =0;i<_paragraphs.length;i++)

{

        if(_paragraphs.lines[-1].words.length == 1)

        {

                alert(_paragraphs.lines[-1].contents);

            }

    }

Regards,

Chinna

TᴀW
Legend
September 1, 2014

What sort of chars? Please specify exactly what you want to include, and

what not...

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Inspiring
September 2, 2014

Hi,

For 'character find' update below code in Line 6 (in "chinna script")

if(para.lines[-1].characters.length <=5)

by

hasvi

BEGINNER_X
Legend
September 2, 2014

Hi Vetha,

By combine Chinna and hasvi script, your requirement is completed.

Even though I create a script for your better output.

As you are beginner, so I use alert in the provided script.

Coding is below:

var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

alert(myParas.length)

for(i=0; i<myParas.length; i++)

{

   if(String(myParas.lines[-1].contents).match(/^\r/) != null)

    {

      continue;

     }

    if(myParas.lines[-1].characters.length<5)

    {

        app.select(myParas.lines[-1]);

        alert(myParas.lines[-1].contents)

        }

    }

Regards

Siraj