Finding and Changing "first word character syle" in text

I want to search spesific word and only replacing first founded word character style in text. Like this :
"Transfer to Istanbul Airport for morning flight to Adana.  Meet and transfer to Antioch , the place where the followers of Jesus were first called Christians. Here you will visit the Church of St. Peter, a grotto discovered by the Crusaders and reputed to be the cave church where early Christians met in secret. At the Mosaic Museum in Antioch you will see an unusually rich collection of mosaics from this area. Following your visit at the museum, you will go to the Seleucia Pieria, the ancient port town of Antioch from which Paul and Barnabas set out on their first journey and where Paul returned afterwards.  Finaly, you will check into the hotel in Antioch for dinner and overnight. (B,D)"
This paragraph contains 4 Antioch word. And I want to make BOLD first one.
This is my code but this code change all of them to bold. Can anyone help me?
var myDocument = app.documents.item(0);
// Clear old preferences
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.includeFootnotes = false;
app.findChangeTextOptions.includeHiddenLayers = false;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = false;
app.findChangeTextOptions.wholeWord = false;
// This CharacterStyle set to BOLD FONT STYLE
app.changeTextPreferences.appliedCharacterStyle = myCharacterStyle;  
app.findTextPreferences.findWhat = "Antioch";
app.changeTextPreferences.changeTo = "Antioch";
myDocument.changeText();

@cuneytoral – the explanation is:
findText() ( or findGrep() ) are methods that return an array of found texts (formatted text objects).
So the result with index 0 is the first one found. The last one is the length of the array -1.
Since the result is of type Array and not Collection, we cannot define a range with the itemByRange() method.
And also we cannot define the last item as allFoundItems[-1], but to have write this:
allFoundItems[allFoundItems.length-1].appliedCharacterStyle = myCharacterStyle;
to address the last found one.
Say, we want to format the found texts from the second one found to the last one found, we have to loop through the found array:
We do not start the loop with 0, but with 1:
for(var n=1;n<allFoundItems.length;n++){
    allFoundItems[n].appliedCharacterStyle = myCharacterStyle;
Formatting every other of the found texts would be:
for(var n=0;n<allFoundItems.length;n=n+2){
    allFoundItems[n].appliedCharacterStyle = myCharacterStyle;
Just to give you some ideas…
Uwe

Similar Messages

  • Possible bug in inDesign CS5 with find and change

    This could be a problem with my script or it may be a bug, not sure.
    The script is used for finding a double space in a fragment of text and changing it to single space.
    It works only once when it is executed.
    To make it work again you have to close and reopen inDesign.
    Here's the code:
    app.findTextPreferences.findWhat = "  ";
    app.changeTextPreferences.changeTo = " ";
    app.documents[0].changeText();

    This one worked, Harbs also works but I think I'll go the unicode grep route for find and change on this one.
    I like the use of the positive lookbehind GREP character. (?<=) 
    thank you

  • Replace all up to the first word character

    I have a String with a value of *1. Artist - Title*. What I am trying to do is remove everything up to the first word character so the new String will be Artist - Title. This is all I have been able to come up with:track.replaceAll ("\\d ^\w","").split (" - ");{code} Also, I used {code:java}track.replaceFirst ("\\d","").replaceFirst ("\\W","").replaceFirst ("\\s",""){code}but that isn't practical at all (even though it works).
    I tried to find examples on a few regular expression sites, but maybe I'm not searching with the right keywords. My code won't even compile. Anyone have a hint?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    public class RegexExample3 {
        public static void main(String[] args) {
            String input = "1. Artist - Title";
            String output = input.replaceFirst("^[^A-Za-z]*", "");
            System.out.format("'%s' ==> '%s'%n", input, output);
    }For your requirements, you need to be cleared about "word character", since \w means [A-Za-z0-9]

  • Interactive Report - is there a way to find and change if necessary the unique column.

    While creating an interactive report I accidently entered the wrong "unique column" on the sql query page.  Is this a big deal and how can I find and change if necessary.
    Query Builder
    Link to Single Row View
    Yes
    No
    Uniquely Identify Rows by
    ROWID
    Unique Column
    Unique Column

    33ac2d45-960f-45af-acba-507f01d18e08 wrote:
    Please update your forum profile with a real handle instead of "33ac2d45-960f-45af-acba-507f01d18e08".
    While creating an interactive report I accidently entered the wrong "unique column" on the sql query page.  Is this a big deal and how can I find and change if necessary.
    Query Builder
    Link to Single Row View
    Yes
    No
    Uniquely Identify Rows by
    ROWID
    Unique Column
    Unique Column
    Yes. You can change this using the Uniquely Identify Rows by/Unique Column properties in the Link Column section on the Report Attributes tab of the interactive report definition.

  • How do I find and replace a word in PDF?

    How do I find and replace a word in PDF?

    In the Find window (Ctrl+F) there's an option to replace the searched text.
    This is in Acrobat XI, and there's no Replace All-function.
    On Thu, Jan 15, 2015 at 4:27 PM, claireb88184899 <[email protected]>

  • How can I hide what I write in a find and change list

    I've written a find and change script, I prepared to offer it for anyone to use, but I don't want to anyone to read what I write in the find and change list.
    How Can I hide it?

    OK, my be offer it for someone to use it, I mean in house coworker, no any virus in it.
    How can hide the find and change list, or change it to another format, not just .txt.
    mybe change it to .doc or .vb or .js, and the script still can run well.

  • How to modify Find and Change indicator?

    I use Find and Change in Applewors 6. At present, this operation finds what is specified but the indicator is colored green and is open, and hard to locate on a page when looking for a single letter. I changed it from its original pale orange to what it is now but now I would like to change it back to something easier to find. But I forgot how I did it and did not make a note. Would appreciate info on how to change this indicator. Thanks

    Neil--
    Thanks for info. I found it under System preferences>Personal>Appearance. You get a lot of choices in color and intensity. I was hoping to change the Find and Change indicator to solid but maybe this is not possible.

  • Text find and change problem in CS3 and CS4 script

    I use the script below to find some text and change into others.
    There is one thing the script can't do it for me.
    Example:
    (g) Management
    (1) that no law which is enacted in the Cayman Islands imposing any tax to be levied on profits, income, gains or appreciation shall apply to the Company or its operations; and
    (2) that the aforesaid tax or any tax in the nature of estate duty or inheritance tax shall not be payable on or in respect of the shares, debentures or other obligations of the Company.
    Example:(END)
    I got a lot of topics or points in the passage. And I want to change the space between '(g)' and 'Management' into a tab character. So I revised the plain text file 1text.
    PS: 1text.txt is filled with what to change.
    text {findWhat:"^p(^?) "} {changeTo:"^p(^?)^t"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all space-dash-space and replace with an en dash.
    The result is:
    (^?)^tManagement
    (^?)^tthat no law which is enacted in the Cayman Islands imposing any tax to be levied on profits, income, gains or appreciation shall apply to the Company or its operations; and
    (^?)^tthat the aforesaid tax or any tax in the nature of estate duty or inheritance tax shall not be payable on or in respect of the shares, debentures or other obligations of the Company.
    PS: ^t is a tab character.
    result (END)
    This is not what I want.
    It should be '(g)^tManagement'.
    PS: ^t is a tab character.
    Please someboady help me out to revised the script below to change the text into what I want. Thanks so much.
    Here is the script.
    //FindChangeByList.jsx
    //An InDesign CS4 JavaScript
    @@@BUILDINFO@@@ "FindChangeByList.jsx" 2.0.0.0 10-January-2008
    //Loads a series of tab-delimited strings from a text file, then performs a series
    //of find/change operations based on the strings read from the file.
    //The data file is tab-delimited, with carriage returns separating records.
    //The format of each record in the file is:
    //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
    //Where:
    //<tab> is a tab character
    //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
    //findProperties is a properties record (as text) of the find preferences.
    //changeProperties is a properties record (as text) of the change preferences.
    //findChangeOptions is a properties record (as text) of the find/change options.
    //description is a description of the find/change operation
    //Very simple example:
    //text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double dashes and replace with an em dash.
    //More complex example:
    //text {findWhat:"^9^9.^9^9"} {appliedCharacterStyle:"price"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find $10.00 to $99.99 and apply the character style "price".
    //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
    //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
    //as shown in the example below:
    //{findWhat:"\\s+"}
    //For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html
    //or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
    main();
    function main(){
    var myObject;
    //Make certain that user interaction (display of dialogs, etc.) is turned on.
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    if(app.documents.length > 0){
      if(app.selection.length > 0){
       switch(app.selection[0].constructor.name){
        case "InsertionPoint":
        case "Character":
        case "Word":
        case "TextStyleRange":
        case "Line":
        case "Paragraph":
        case "TextColumn":
        case "Text":
        case "Cell":
        case "Column":
        case "Row":
        case "Table":
         myDisplayDialog();
         break;
        default:
         //Something was selected, but it wasn't a text object, so search the document.
         myFindChangeByList(app.documents.item(0));
      else{
       //Nothing was selected, so simply search the document.
       myFindChangeByList(app.documents.item(0));
    else{
      alert("No documents are open. Please open a document and try again.");
    function myDisplayDialog(){
    var myObject;
    var myDialog = app.dialogs.add({name:"FindChangeByList"});
    with(myDialog.dialogColumns.add()){
      with(dialogRows.add()){
       with(dialogColumns.add()){
        staticTexts.add({staticLabel:"Search Range:"});
       var myRangeButtons = radiobuttonGroups.add();
       with(myRangeButtons){
        radiobuttonControls.add({staticLabel:"Document", checkedState:true});
        radiobuttonControls.add({staticLabel:"Selected Story"});
        if(app.selection[0].contents != ""){
         radiobuttonControls.add({staticLabel:"Selection", checkedState:true});
    var myResult = myDialog.show();
    if(myResult == true){
      switch(myRangeButtons.selectedButton){
       case 0:
        myObject = app.documents.item(0);
        break;
       case 1:
        myObject = app.selection[0].parentStory;
        break;
       case 2:
        myObject = app.selection[0];
        break;
      myDialog.destroy();
      myFindChangeByList(myObject);
    else{
      myDialog.destroy();
    function myFindChangeByList(myObject){
    var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;
    var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;
    var myStartCharacter, myEndCharacter;
    var myFindChangeFile = myFindFile("/FindChangeSupport/1test.txt")
    if(myFindChangeFile != null){
      myFindChangeFile = File(myFindChangeFile);
      var myResult = myFindChangeFile.open("r", undefined, undefined);
      if(myResult == true){
       //Loop through the find/change operations.
       do{
        myLine = myFindChangeFile.readln();
        //Ignore comment lines and blank lines.
        if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")||(myLine.substring(0, 5)=="glyph")){
         myFindChangeArray = myLine.split("\t");
         //The first field in the line is the findType string.
         myFindType = myFindChangeArray[0];
         //The second field in the line is the FindPreferences string.
         myFindPreferences = myFindChangeArray[1];
         //The second field in the line is the ChangePreferences string.
         myChangePreferences = myFindChangeArray[2];
         //The fourth field is the range--used only by text find/change.
         myFindChangeOptions = myFindChangeArray[3];
         switch(myFindType){
          case "text":
           myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
           break;
          case "grep":
           myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
           break;
          case "glyph":
           myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
           break;
       } while(myFindChangeFile.eof == false);
       myFindChangeFile.close();
    function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
    //Reset the find/change preferences before each search.
    app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences = NothingEnum.nothing;
    var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";
    myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";
    myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";
    app.doScript(myString, ScriptLanguage.javascript);
    myFoundItems = myObject.changeText();
    //Reset the find/change preferences after each search.
    app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences = NothingEnum.nothing;
    function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
    //Reset the find/change grep preferences before each search.
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences = NothingEnum.nothing;
    var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";
    myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";
    myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";
    app.doScript(myString, ScriptLanguage.javascript);
    var myFoundItems = myObject.changeGrep();
    //Reset the find/change grep preferences after each search.
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences = NothingEnum.nothing;
    function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
    //Reset the find/change glyph preferences before each search.
    app.changeGlyphPreferences = NothingEnum.nothing;
    app.findGlyphPreferences = NothingEnum.nothing;
    var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";
    myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";
    myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";
    app.doScript(myString, ScriptLanguage.javascript);
    var myFoundItems = myObject.changeGlyph();
    //Reset the find/change glyph preferences after each search.
    app.changeGlyphPreferences = NothingEnum.nothing;
    app.findGlyphPreferences = NothingEnum.nothing;
    function myFindFile(myFilePath){
    var myScriptFile = myGetScriptPath();
    var myScriptFile = File(myScriptFile);
    var myScriptFolder = myScriptFile.path;
    myFilePath = myScriptFolder + myFilePath;
    if(File(myFilePath).exists == false){
      //Display a dialog.
      myFilePath = File.openDialog("Choose the file containing your find/change list");
    return myFilePath;
    function myGetScriptPath(){
    try{
      myFile = app.activeScript;
    catch(myError){
      myFile = myError.fileName;
    return myFile;

    It takes me a lof of time to comprehend the sentence you write. Cause I am a Chinese. My poor English.
    I have to say "you are genius". I used to use the indesign CS2. There is no GREP function in CS2. When I get the new script, I do not know how to use it. Just when I saw the
    'grep {findWhat:"  +"} {changeTo:" "} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double spaces and replace with single spaces.'
    Being confused.
    Thanks so much. It seems I have to relearn the advanced Indesign.

  • Can I create action to Save As...  and change only one character of the original file name?

    I'm working on a group of  files(25-28) at a time. I have to save each one as a photoshop .raw file and change the first character of the file name. the rest of the file name must remain the same. I then close the original file with no changes. I tried to create an action for this. The only problem is that the next file overwrote the file I used to create the action.  Is it possible to creat an action to save as... and keep the file name of the new file but chage the first character to the same one used in the recording?

    Good day!
    I think what you are describing is not possible with Actions.
    Scripting would be an option, but more convenient might be simply saving the files with unchanged names and then edit the names of  the whole bunch in Bridge in one go (Tools > Batch Rename).
    Regards,
    Pfaffenbichler

  • How can I find and replace multiple words at once?

    I need to be able to find and replace words into queens English. For example, I need to replace all instances of "color" with "colour," "tire" with "tyre" etc.
    I'm new to scripting, so simple answers would be appreciated :)

    Hi hobs707,
    Please use the below code for your required output:
    Replace ("color", "colour")
    Replace("tire", "tyre")           
    //Replace("hobs707", "hobs007")     just copy and paste and edit the contents as your wish
    function Replace(input, output)
    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences.findWhat = input;
    app.changeTextPreferences.changeTo = output;
    app.activeDocument.changeText();
    If the above answer is correct please provide Correct Answers for me.
    Regards
    Beginner

  • How to find and remove any special character in filename?

    I have a files in various Windows Servers 2003 with a special character at his names, who are causing problem with backup software, i don´t know what character is because in explorer they are not shown and in command line they are shown only as interrogation
    mark and for this, i don´t know how i will find and remove then.
    Thanks.

    Hi,
    I agree with Dave. We can try using
    chkdsk utility to check the file system and file system metadata of a volume for logical and physical errors.
    Regarding
    chkdsk, the following article can be referred to for more information.
    Chkdsk
    http://technet.microsoft.com/en-us/library/cc730714.aspx
    Best regards,
    Frank Shen

  • How To: Find and replace multiple words in one Click ?

    I have an file with about 150 Pages where I want to replace a word about 500 time by one click.
    Find and Replace works but only with one word.
    How can I do it by one click ?

    You can't, not in Acrobat anyway.
    This is the kind of thing that should be done in the original file format,
    not in a PDF.

  • Find and change crashing InDesign file

    I'm working on a file and whenever I do a find and replace, it crashes. I recently ran Adobe updater and when I did, the application gave an error that "Scotch Rules" were used on the last saved version and it wasn't loaded on my system. Considering I built this file on my system, I knew I had Scotch Rules. I went into my extension manager and enabled it. This didn't help the crashing. It crashes with this loaded and this not loaded.
    I also trashed my preferences to InDesign using the cmd+opt+cntrl+shift as well as by hand by going to the folders. Nothing is working
    Any ideas?
    Thanks in advance!

    Peter Spier Thanks for replying to another one of my posts. I tried what you suggested here and it didn't work. Actually, I found that when I "saved as" an IDML, it wouldn't save a file at all. It would have a temporary "lock" icon as if making one on the desktop, but no file would finalize and appear. I also reinstalled the applications from the disk image I downloaded through the creative cloud and that didn't solve the problem. I then corrected disk permissions in Apple's Disk Utility. That didn't work either.

  • Finding and changing ownership of files by uid

    In migrating to a laptop to allow the primary account to be a mobile user on a server, I deleted the user account. Since this user was also the admin for the machine, I now have a series of applications and files on the box which show 501:501 as the owner and group. I can use find to find the files. What I am searching for is the command that would allow me to pipe that to chown so I can modify all these files. Yes I do have a back-up.
    Is it something like:
    sudo find / -uid 501 | chown admin:admin
    And then I could repeat to get the remaining 501 group with:
    sudo find / -gid 501 | chown :admin
    Thanks!

    I suggest using xargs. Use -print0 on 'find' and -0 with xargs (those are zeros).
    Something like:
    find / -uid 501 -print0 | xargs -0 chown admin:admin
    (I didn't fully test it -- ran with 'echo' instead of chown )

  • Find and Change in PDF

    Is there a way to find change in Acrobat Pro--any version-- Lets say you want to change all instances of the word "state" to the word "city"
    Is this possible with todays technology to do this in a PDF?
    Thanks
    ...I entered in this question in the ask a qustion area, but not sure if it went through...sorry if I double posted this.
    p

    Only in Acrobat Pro XI (not sure about the Standard version), and only one at a time, there's no Replace All function.

Maybe you are looking for

  • Problem about Installation J2SDK1.3.1 on Solaris 2.6

    hi,happy new year everyone, I have installed J2SDK1_3_1_02-solsparc.sh on Solaris 2.6, and it prompted to me installation sucessfully. but when I run javac or other commands, it prompts to me the following error: *************************************

  • Regarding ALV report heading

    Hi to all I am preparing a ALV report. In which I want to display the values which are entered on selection screen. On the selection screen these are the fields : s_werks for pa0001-werks s_orgeh for pa0001-orgeh I am successful to capture one value

  • Safari allows 3rd party cookies and all cookies even when prefernces are set to "never allow" with Mac os 10.6.8

    safari ALWAYS allows 3rd party cookies and all cookies even when set to "block cookies: always" and "from 3rd party and advertisers."  I have removed the website data, emptied the cache, reset safari, erased the history and it STILL dumps cookies.  (

  • G4 tower as file server

    Ok i have a Tower i use as a storage server for multiple macs in my house My problem is that i know how to set permissions to discs to read only for other users on the tower but how do i st up permissions to read only when other users connect from ot

  • 10.4.6 extreme slowdown and swapfile use

    I have an i7 15" with 4gb ram and 80gb free space on its disk. I had installed Safari 5 before getting the MacOSXUpdCombo 10.6.4. After the install the problem started. An extreme slowdown with few programs open. I like to keep an eye on swapfile spa