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

help with little script using grep

New Here ,
Sep 14, 2009 Sep 14, 2009

Copy link to clipboard

Copied

i am a begginer but i guess this will not be a problem for somebody who is experienced...

i am working with a lot of files that have tags. tag for italic text, tag for centered text and so on, i manage to

get regular expression to work and to do all of these things with find/change dialog, but i would like to

automate all of it..

so for example i have part of the text that need to be italic that is enclosed in underscores like this _something that needs to be italic_

and i have this regular expression that takes care of it _[A-Za-z0-9,;\-\?\(&!\):'". ]+_

finds all the matches and applies the text style i want.

how to do that with script? thanks in advance.

TOPICS
Scripting

Views

1.4K

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
New Here ,
Sep 14, 2009 Sep 14, 2009

Copy link to clipboard

Copied

any hints?

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
Guide ,
Sep 15, 2009 Sep 15, 2009

Copy link to clipboard

Copied

Use FindChangeByList.jsx (with 'grep' findType).

@+

Marc

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
New Here ,
Sep 15, 2009 Sep 15, 2009

Copy link to clipboard

Copied

ok, ok tried that, i opened FindChangeList.txt and changed one line and uncommented it

here is who it looks:

grep  {findWhat:"_[A-Za-z0-9,;\-\?\(&!\):'. ]+_"}  {applied paragraph style:paragraph style "boldanditalic"} {includeFootnotes:true}  finad and change to ita

and it doesnt work

i tried some of the text examples and they do work...what is going on? is there any simple test to try?

(this regex works in find/change dialog)

thanks again for the effort

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
Guide ,
Sep 15, 2009 Sep 15, 2009

Copy link to clipboard

Copied

I think you need to escape the backslashes:

{ findWhat : "_[A-Za-z0-9,;\\-\\?\\(&!\\):'. ]+_" }

Just a question, why not using this:

{ findWhat : "_[^_]+_" }

@+

Marc

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
New Here ,
Sep 16, 2009 Sep 16, 2009

Copy link to clipboard

Copied

oh, you are write your expression work like a charm "_[^_]+_"

the point is that i needed something fast and didnt know regex very well, and i am still a beginner..

also, this works only in find/change dialog but not when i try to run a script ;( here is the line that i uncomented in the FindChangeList.txt

grep  {findWhat : "_[^_]+_"}  {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:true}     description

i am not sure do i need stuff enclosed in third pair of parethesis...

anyhow, i save this file and ran the script from indesign...nothing happens

maybe it is a bug...i tried some of the lines that deal with text and that worked like a charm but grep dont.

thanks for helping me.

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
New Here ,
Sep 16, 2009 Sep 16, 2009

Copy link to clipboard

Copied

ok, i made it to work with countless tries, and it works but only first time, and i undo and run script again it doesnt work (text does but grep dont)

i then need to restart indesign to make it work again...what a hell is going on???

how to make this work as it should?? thanks guys!

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
Community Expert ,
Sep 16, 2009 Sep 16, 2009

Copy link to clipboard

Copied

Going back to your first GREP, search for this

_([A-Za-z0-9,;\-\?\(&!\):'". ]+)_

and replace with

$1

(with formatting in italic and/or your style) will do the formatting and remove the underscores at the same time. Only if you are totally sure the underscores are balanced, use

_([^_])_

-- if there is only one single unbalanced one, it'll mess up your text.

It should work correct in the interface; to put it into the findreplace script file, double the backslashes -- that's all.

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
New Here ,
Sep 17, 2009 Sep 17, 2009

Copy link to clipboard

Copied

LATEST

thanks everybody, i manage to get it work taking into account what was written here...it all comes down to this:

cs3 findchangelist script messes up indesign, i am using cs4 version and it doesnt give any problems

line that i am using for italic is:

grep    {findWhat:"_[A-Za-z0-9,;\\-\\?\\(&!\\):'\".~b/]+_"}    {appliedFont:"Adobe Garamond Pro", fontStyle:"Bold Italic", pointSize:13}    {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true}    //Comment

thanks again!

@[Jongware]

thanks, i am back to the old grep!

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