Search for a word in "()" and apply CharacterStyle

Sorry my bad English

I need your help

I can search in a parenthesis with------((.*)------)

ex: Hello Goodbye (World), must apply to a CharacterStyle '(World)' with CharacterStyle


hello (world) bye

similar script:


var active_doc = app.activeDocument;  
  
var search_string = /\((.*)\)/ig;


  
var text_frames = active_doc.textFrames;  


var italicStyle = active_doc.characterStyles["italica"];  


if (text_frames.length > 0)  
{  
    for (var i = 0 ; i < text_frames.length; i++)  
      {  
          var this_text_frame = text_frames[i];  
   
  italicStyle.applyTo(this_text_frame.textRange);  


             
           if (new_string != this_text_frame.contents)  
               {  
                    this_text_frame.contents = new_string;  
               }  
      }  
}  





Thanks, sorry my bad English I speak Spanish

var frames = app.activeDocument.textFrames;
for (var j = 0; j < frames.length; j++){
var text = frames[j].textRange;
var italicStyle = app.activeDocument.characterStyles["italica"];
var haystack = text.contents;
var needle = /[\(]([^\)]*)[\)]/gi;
var match;
while(match = needle.exec(haystack)){
var start = needle.lastIndex - match[0].length;
var end = match[0].length;
for (var i = 0; i< end; i++){
italicStyle.applyTo(text.characters[i + start]);
}
}
}

Tags: Illustrator

Similar Questions

  • title search for the words HTTP and 404. __

    I am unable to get the photo galleries to display on this site that I would use often:http://english.vietnamnet.vn/en/vietnam-in-photos/349/hanoi-s-folk-festivals-in-old-photos.html

    Technical information (for support personnel)

    Hi Gowest,

    • Were you able to see the photos earlier on this site?
    • Are you able to see the pictures on other sites?

    This seems to be a problem with the Web site. Even I tried to access the link and I was unable to see the pictures on this particular link and it shows red x instead of the image and clicking on it gives the same error you posted.

    You can communicate with the support of Web site to check if they have any problems with the images in the link of the Web site.

    I hope this helps.

    Thank you and best regards,

     

    Srinivas R

    Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Search for the strings "BOLD" and apply XML tags that already, I created manually...

    Dear friends,

    I want to string (strings that are "BOLD") the search of my document textframe and ask xmltags who... I worked with the codes below... But it doesn't quite work...  (b "BOLD" tag with a color label)

    docObj = app.activeDocument;

    xmlObj = docObj.xmlTags;

    app.findTextPreferences = app.changeTextPreferences = null;

    app.findTextPreferences.findWhat = '(.+)';

    app.findTextPreferences.fontStyle = "Bold";

    app.changeTextPreferences.changeTo = docObj.xmlImportMaps.xmlObj.tags.item(name:b);

    docObj.mapXMLTagsToStyles ();

    Thank you and best regards,

    Vel.

    Finally, I got the correct codes after no. attempts, I tried...

    Here is the code:

    docObj = app.activeDocument;

    xmlObj = docObj.xmlTags;

    pageObj = docObj.pages.item (0);

    myTextFrame = pageObj.textFrames.item (0);

    myText = myTextFrame.parentStory.paragraphs.item (0);

    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences.fontStyle = "Bold";

    xmlObj = app.changeTextPreferences.markupTag [0] .name;

    Alert (App.changeTextPreferences.markupTag);

    app.activeDocument.changeText ();

    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences.fontStyle = "Bold Italic";

    xmlObj = app.changeTextPreferences.markupTag [1] .name;

    Alert (App.changeTextPreferences.markupTag);

    app.activeDocument.changeText ();

    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences.fontStyle = "italic";

    xmlObj = app.changeTextPreferences.markupTag [2] .name;

    Alert (App.changeTextPreferences.markupTag);

    app.activeDocument.changeText ();

    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences.capitalization = Capitalization.SMALL_CAPS;

    app.changeGrepPreferences.markupTag = xmlObj [4] .name;

    Alert (App.changeGrepPreferences.markupTag);

    app.activeDocument.changeGrep ();

    Thank you

    Vel...

  • Search for a word in a Web page

    Hello

    I have a little problem on the search in a web page.

    Without worrying to highlight what is useful in all software, how can I search for a word in a Web page?

    I mean imagine in windows, through the web page, you need to find the word "except", if you come to use the Toolbox in the browser and type except to indicate each word "except" in this page and highlight it. Is there a similar option for safari for Mac too?

    F command should do what you want. -AJ

  • Search for a word in all my files on the mac HD

    Is there a function in the application of SEARCH to the search for a word or phrase in all my files to my Mac Book Pro HD?

    Have you tried spotlight and searched on "content?  See this discussion.

  • Search for several words in SQL

    I want to be able to search on multiple words in sql.  If someone entered in the field search for several words like "industry of corn for biofuels". I want to return all records that has one of these words in them.  Here is my code: (brings back only the sentence and not individual words in the database)

    and)
    path as < cfqueryparam cfsqltype = "cf_sql_varchar" value="%#arguments.searchterms#%" > "
    or
    the body as < cfqueryparam cfsqltype = "cf_sql_longvarchar' value="%#arguments.searchterms#% ">"
    or
    Summary as < cfqueryparam cfsqltype = "cf_sql_varchar" value="%#arguments.searchterms#%" > "
    or
    the author as < cfqueryparam cfsqltype = "cf_sql_varchar" value="%#arguments.searchterms#%" > "
    )

    something like this:

    Select somefields

    of sometables

    where 1 = 1

    and

    (

    or concat (Field1, Field2, etc.) like ' %#word #% ".

    or 1 = 2

    )

    Just to let you know, it will be slow.   Also, if one of these fields accept NULL values, you will have to deal with that.

  • How can I find Notes? I have a lot so I need to search for key words

    How to search for key words in the Notes?

    Use Spotlight search.

    Go to settings > general > Spotlight search to check that Notes is included in the search.

    To open the Spotlight search shot down with one finger begin in the middle of the home screen.

  • How can I search for a word in several files in a particular folder?

    Original title: search for a specific word

    Hello

    I'm working on Windows 8. How can I search for a word in several files in a particular folder?

    TKS

    Provide the location is indexed, you can search for a specific phrase or Word file Explorer by typing content: follow-up of your phrase surrounded by quotation marks. This will produce a list of files, the filtering criterion.

  • REGEXP_LIKE and search for whole words in a string

    Try to find a way to use regexp_like (in 11 GR 2) to find whole words, not partial, within a string.

    For example:
    create table regex_test (id int, name varchar2(30));
    
    insert into regex_test values (1, 'John featuring Jane');
    insert into regex_test values (2, 'Featuring John and Jane');
    insert into regex_test values (3, 'John and Jane');
    insert into regex_test values (4, 'John featuring');
    insert into regex_test values (5, 'John with Jane');
    insert into regex_test values (6, 'John and Jane within intro');
    The goal here is to find all names that contain the words 'featuring' and 'with '. Case-insenstive. Does not not on ' in the '.

    We are looking for hits on ID 1, 2, 4 and 5 and have not been able to find a good example there.

    Thank you
    Todd

    Hello

    Here's one way:

    ...
    WHERE     REGEXP_LIKE ( ' ' || name || ' '
                  , '( featuring )|( with )'
                  , 'i'
                  )
    

    This assumes that the words are separated by spaces, no legs or punctuation. If this isn't the case, then it's a bit messier; Maybe

    WHERE     REGEXP_LIKE ( ' ' || name || ' '
                  , '(\Wfeaturing\W)|(\Wwith\W)'
                  , 'i'
                  )
    

    \W means anything that is not usually a part of a Word.

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

    Published by: Frank Kulash, February 8, 2011 14:17
    \W version added

  • Can I search for a word in the description of a bookmark?

    When I add a bookmark, I often add a description.
    Another reason why a lot of my favorites are the descriptions is that I am an old user of delicious and I imported these bookmarks in Firefox.
    So I would like to search for words that I wrote in the description, because the description is often more significant than the label, the name or the URL.
    But unfortunately Firefox does not resemble the description during the search in bookmarks.
    Nor find any extension.

    A backup of bookmarks HTML includes descriptions, so you could open such a backup in a tab and use the search bar to search the page.

    You can make Firefox create an automatic HTML (bookmarks.html) backup when you exit Firefox, if you set the pref to true on the subject browser.bookmarks.autoExportHTML: config page.

    This backup is created by default in the profile as bookmarks.html folder whenever you close Firefox, but you can set the file name and the path through the pref browser.bookmarks.file on the topic: config page.

    The pref browser.bookmarks.file does not exist by default and you must create a new pref to string with the name browser.bookmarks.file and set the value to the full path of the file backup bookmarks including the name of the file.

  • How to search for a Word document in Windows 8?

    I'm stumbling around Windows 8 that came pre-loaded on my new laptop.  I ordered Windows and Excel to be included in the package.  I saved a number of documents in Word, and now I need to get these documents for a particular.  I looked on the Internet and found a lot of no-help, that is to say, 'go in search of a file'.  Excuse me, but if I could find searching a file, I could probably find out how to search for the file, Huh?  Thus,.

    Could someone please help me with: how to find a Word document (1) and (2) where is the infamous "search"?

    I did the thing 'sweep to the right side of the screen"to get those things shadow to appear, and click on the magnifying glass (which I think the engineers forgot to change when they changed everything!) and if I wanted to search for apps, I'd be in great shape.  But his files I'm looking for, Word documents.  The designers of this 'new' version improved - well, new, in all cases seem to have forgotten those of use who use computers for productive work and not socialize or play games.

    Sorry for the hike and whining, but I'm very frustrated that the tasks that were once very simple are now extremely difficult to fill.

    It's pretty easy, at the beginning screen just type the name of your document and right it will bring the search screen and you select files (files, settings, Apps). Take a look at:

    http://Windows.Microsoft.com/en-us/Windows-8/search-apps-files-settings

  • Acrobat XI can search for several words at a time?

    Every day I check a long list of words in a new and large file I'm sent. I tried to look up these words doing a single search query, but it seems that it's not possible. In the advanced search section I hace tried to do queries like word1 word2, nothing. Word1 AND word2, nothing. Word1 + word2, nothing. Nothing works. Can search for acrobat even more than one word at a time?

    Thanks for your comments.

    Kind regards.

    Jose.

    Of course, it is possible. In the advanced search window, press show more Options then select 'Match any of the words' under the heading "Return results containing" and enter your search terms separated by a space, like this:

  • After that 5 weeks back to Japan, Firefox still gives me Japanese sites - for example, search for 'cat' in ff and I get Japanese wikipedia, the same search in English product Safari. Boring!

    After his return from 5 weeks to the Japan, Firefox still gives me Japanese sites - for example, if I search for 'cat' in Google using Firefox and I get Japanese Wikipedia and a whole bunch of other Japanese sites. If I repeat the same search in Safari, I get the English Wikipedia. I read Japanese, but this does not mean that I want all the time! How can I fix?

    Clear the cache and cookies from sites that cause problems.

    "Clear the Cache":

    • Firefox > Preferences > advanced > network > storage (Cache) offline: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Firefox > Preferences > privacy > Cookies: "show the Cookies".
  • I can search for a file "xyz" and find everything BUT the file I want. This happens even when I know that the file exists.

    I try to search for a file... choose any file name... like 'cat' but get everthing that doesn't even look like a cat.  I can get a list of files of a thousand, but anything containing same cat in the filename OR in the file. No idea what I am doing wrong?

    John

    Hello

    "Maybe" there is something in the search Index that is causing a problem or try the advanced options
    Search.

    Windows Search does not work or research are slower
    http://support.Microsoft.com/GP/windows_search

    Troubleshooting Windows Vista search & indexing errors
    http://www.WinVistaClub.com/T24.html

    Reconstruction of the Index in Windows Vista
    http://www.howtogeek.com/HOWTO/Windows-Vista/rebuilding-the-search-index-in-Windows-Vista/
    How to enable or disable the search Index in Vista
    http://www.Vistax64.com/tutorials/69564-index-enable-disable.html
    Improve Windows searches using the index: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows-Vista/improve-Windows-searches-using-the-index-frequently-asked-questions

    ================================

    Tips for finding files
    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-finding-files

    How to use advanced search in Vista Options
    http://www.Vistax64.com/tutorials/75451-advanced-search.html

    How to restore the page button on the Start Menu after installing Vista SP1
    http://www.Vistax64.com/tutorials/145787-Search-start-menu-button-restore-after-SP1.html

    How to restore the context Menu item search after installing Vista SP1
    http://www.Vistax64.com/tutorials/134065-search-context-menu-item-restore-after-Vista-SP1.html

    How to create a shortcut on the desktop search in Vista
    http://www.Vistax64.com/tutorials/126499-search-desktop-shortcut.html

    ----------------------------------------------------------

    Win Key F opens advanced search

    Searching in Windows Vista, part 1
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-1-secrets-of-the-search-box

    Part 2
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-2-Start-menu-and-control-panel-search-tips

    Part 3
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-3-using-advanced-search-for-those-hard-to-find-files

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • How to use the find method to search for character format substitutions and FMP?

    I strongly suspect that I should be able to use the find method to search for paragraph substitutions and format as these options are available in the Find dialog box. However, because of the excruciating Extendscript documentation from Adobe, I not was able to find the key pieces of information that I need. I found these constants:

    • Constants.FV_FindPgfFormatOverride
    • Constants.FV_FindCharacterFormatOverride

    But he has literally no information about them. It is not yet a definition, so I'm actually just a guess. However, I think that I need to somehow use these constant within the parameters of the Find method. Any ideas on how to do it?

    You're right, there are still some bugs to work out of the documentation, although it has already improved since I started w / Extendscript last summer.

    Find two constants must be defined as the ival for a PropVal FindObject, for example:

    var myDoc is app. ActiveDoc;

    var docStart = myDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

    tloc var = new TextLoc(docStart,0);

    var findParams = AllocatePropVals (1);

    findParams [0].propIdent.num = Constants.FS_FindObject;

    findParams [0].propVal.valType = Constants.FT_Integer;

    findParams [0].propVal.ival = Constants.FV_FindCharacterFormatOverride;

    myDoc.Find (tloc, findParams);

    Depending on what you're trying to accomplish, you can also take a look at the property FormatOverride of the Doc, bmp and item objects.

Maybe you are looking for