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

Change Line-Breaks in Paragraphs by GREP/regex

Explorer ,
Dec 04, 2018 Dec 04, 2018

Here is my Problem:
A Text set in CS6 uses a different character for Line-Breaks as CC.
Now there is the idea to run a script in CC2019 to convert Forced-Line-Breaks in Paragraphs via GREP/regex.

This code works, but not for those Line-Breaks. I didn't figure out the character.

// regex_changeContentsOfWordOrString_RemainFormatting.jsx   // regards pixxxel schubser    /* var s = /(\r\n|\r|\n)/; */  /* var s = /\u000D/; */  /* var s = /\u000C/; */  /* var s = /^n/; */  var s = /\n/; /* var s = /\u000A/; */ /* var s = /\u000D/; */ /* var replacer = "hello", result; */ /* var replacer = "bla", result; */   /* var replacer = "\r", result; */ var replacer = /\r/, result;  var atf = activeDocument.textFrames[0];      while (result = s.exec(atf.contents)) {       try {           aCon = atf.characters[result.index];           aCon.length = result[0].length;           aCon.contents = replacer;           } catch (e) {};       }

Which character is it?

ai-Line-End-in-Paragraph.png

And here is the download-link for the test-file:
BlocksatzCS6.ai

Changed Line-Endings

TOPICS
Scripting
987
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

Advocate , Dec 06, 2018 Dec 06, 2018

Salut !

var s = new RegExp(String.fromCharCode(3), "g");

  var replacer = "\r",  //  or var replacer = "\n",

      result;

  var atf = activeDocument.textFrames[0];

    while (result = s.exec(atf.contents)) {

      try {

          aCon = atf.characters[result.index];

          aCon.length = result[0].length;

          aCon.contents = replacer;

        } catch (e) {};

    }

de elleere LR

Translate
Adobe
Advocate ,
Dec 06, 2018 Dec 06, 2018

Salut !

var s = new RegExp(String.fromCharCode(3), "g");

  var replacer = "\r",  //  or var replacer = "\n",

      result;

  var atf = activeDocument.textFrames[0];

    while (result = s.exec(atf.contents)) {

      try {

          aCon = atf.characters[result.index];

          aCon.length = result[0].length;

          aCon.contents = replacer;

        } catch (e) {};

    }

de elleere LR

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 ,
Dec 06, 2018 Dec 06, 2018

Thanks alot, this works!!!
Merci beaucoup de votre aider!!!

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
Engaged ,
Jul 14, 2022 Jul 14, 2022
LATEST

Great!

-Sumit
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