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

Change Line-Breaks in Paragraphs by GREP/regex

Explorer ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

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

Views

777

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

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

Votes

Translate

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

LATEST

Great!

-Sumit

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