[AS] Find a string of words in text

Hello - hopefully someone can help as I'm now stuck on this. I want to be able to find a specific string of words within a text frame, though I want to be able to do this without using the Find Text Preferences approach.
I can get it to work if i am just finding one word, but if there is more than one word it doesn't work.
For example this works (given a text frame with text in that contains the word Example):
tell application "Adobe Indesign CS5"
tell active document
set mybox to selected
  tell mybox
   set myfind to object reference of every word whose contents = "Example"
  end tell
end tell
end tell
However the same does not work (searching for "The Example", which is two words)
tell application "Adobe Indesign CS5"
tell active document
set mybox to selected
  tell mybox
   set myfind to object reference of every word whose contents = "The Example"
  end tell
end tell
end tell
What i can't figure out is the correct phrasing for finding a string of words, i guess i should not be looking for the object reference of WORD, but nothing else i've tried seems to work. Many thanks for any help

I think what John has said is correct… I only had a quick look in the dictionary terms. Without find/change the closest you may get is line or paragraph after that you would need to manipulate the line/para contents further… Word by definition I would think can't contain space but is encapsulated in space bar first/last…
tell application "Adobe InDesign CS5"
tell active document
tell story 1
set myfind to object reference of every word whose contents = "Example"
end tell
show text first item of myfind
end tell
end tell
This would show the line you can then break down further…
tell application "Adobe InDesign CS5"
tell active document
tell story 1
set myfind to object reference of every line whose contents contains "For Example"
end tell
show text first item of myfind
end tell
end tell

Similar Messages

  • Regular expression - find if string does NOT contain text....

    I have a string that I want to tokenize. The string can contain basically anything. I want to produce tokens for each "word" found, and for each "<=" or "," found. There does not need to be whitespace around a "<=" or a "," to consider it a token. So for example:
    joe schmoe<=jack, jane
    should become
    joe
    schmoe
    <=
    jack
    jane
    As a constraint, I do not want to use StringTokenizer at all, as "its use is discouraged in new code". http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
    Here's the code I plan on using for this:
        public String[] getWords(String input) {
            Matcher matcher = WORD_PATTERN.matcher(input);
            ArrayList<String> words = new ArrayList<String>();
            while (matcher.find()) {
                words.add(matcher.group());
            return (String[]) words.toArray(new String[0]);
        }The trick, though, is coming up with a working regular expression. The closest I've found yet is:
    ([^\s]|^(,)|^(<=))+|,|<=
    but that produces the following:
    joe
    schmoe<=jack,
    jane
    I think what I need is to be able to find if a string does not contain the substring "<=" or "," using a regular expression. Anyone know how to do this, or another way to do this using regular expressions?

    Try:
    * Tokenizer.java
    * version 1.0
    * 01/06/2005
    package samples;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    * @author notivago
    public class StrangeTokenizer {
        public static void main(String[] args) {
            String text = "joe schmoe<=jack, jane";
            Pattern pattern = Pattern.compile( "((?:<=)|(?:,)|(?:\\w+))");
            Matcher matcher = pattern.matcher(text);
            while( matcher.find() ) {
                System.out.println( "Item: " + matcher.group(1) );
    }May the code be with you.

  • Find a string in a file and write a new text after it

    hi
    i try to search a string in a small text file. after this position I should write a new text (it is not the end of the text, it could be somewhere between).
    I tried to solve this with the StrginTokenizer, but it does not work properly, any other ideas how to solve this?
    thanks for your comments
    steinfresser

    To insert text into the middle of a file you use the process that has been used since the first text editor was invented over 50 years ago:
    1. Read the text from the file up to the insert point, and write it to a new file.
    2. Write the inserted text to the new file.
    3. Read the rest of the text from the file, and write it to the new file.
    4. Delete the file.
    5. Rename the new file.

  • Find and edit specific line in text file?

    Hello I want to read a text file that could look in some different ways since the user choose file from a list. I then want to igonre all the lines that begin with a special character, for example %. I then want to find all the lines "words" that begin with TRY for example and put those "words" in a string or array. If there is one line that contains TRY100 and anoter line that contains TRY200 I want to find those words and display them. How do i do this?

    First you read the entire file.  Use the Read Text File.  Right-click on it and select the option to Read Lines.  The the count to read to -1 (read all).  You will now have an array of strings, one item for each line of your file.
    Now you need to play the filter game.  I recommend using FOR loops with Autoindexing tunnels.  Assuming you are using 2012 or later, have the output autoindexing tunnels use the conditional tunnel.
    Give this a try and see where you can go.  Post back with what you have tried and tell us where you are stuck.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Seachring word from text file

    Hi...There..
    I h'va wrirtten Search application which search words from Simple text files.
    My file contains list of words separated by "\n"(new line).
    i am using java.io.BufferedReader for reading file.
    i'want to search word from file within few milliseconds, but when my file containo more then some 2lake words(200000) my process of readind comsumes more then 5 sec. time to search.
    pl. suggest me effective method to search word from file so i can make it rapid search.
    Actually i 've to provide search on "TEXT VALUE CHANGED EVENT" so even if my process takes more then one seconds it is not physible for me.
    Thanks in Advance.
    Timir Patel.

    Try this:
    import java.io.*;
    import java.util.*;
    public class searcher
              private static long [] indexes;
         private static class temp_data
              public final String text;
              public final long starts_at;
              public temp_data(String t, long l)
                   text = t;
                   starts_at = l;
         private static class temp_cmp implements Comparator
              public int compare(Object o1,Object o2)
                   return ((temp_data)o1).text.compareTo(
                             ((temp_data)o2).text);
         /** creats index table. You should do it once, and rather store index
         table in file then. This method has high peak memory usage but it is
           easy to optimize it.*/
         private static void buildIndex(RandomAccessFile file)throws Exception
              List temp = new LinkedList();
              String st;
              long p = file.getFilePointer();
              while((st = file.readLine())!=null)
                   temp.add(
                        new temp_data(st,p)
                   p = file.getFilePointer();
              Collections.sort(temp,new temp_cmp());
              indexes = new long[temp.size()];
              int i=0;
              for(Iterator I=temp.iterator();I.hasNext();i++)
              temp_data tt = ((temp_data)I.next());
               System.out.println("indexing :"+tt.text+" ["+tt.starts_at+"]");
                   indexes=tt.starts_at;
         /** returns position at which text starts or -1 if not found */
         public static long find(String text,RandomAccessFile file)throws Exception
              int ncp = indexes.length/2;
              int n = 2;
              int cp;
              do{
              cp = ncp;
                   file.seek(indexes[cp]);
                   String tt = file.readLine();
              System.out.println("comparing with "+tt);
                   int cmpr = text.compareTo(tt);
                   if (cmpr==0)
                        return indexes[cp];
                   else
                   if (cmpr>0)
                        ncp = cp+(indexes.length / (1<<n));
                   else
                        ncp = cp-(indexes.length / (1<<n));
                   n++;
              }while(ncp!=cp);
              return -1;
         public static void main(String args [] )throws Exception
              RandomAccessFile f = new RandomAccessFile(args[0],"r");
              buildIndex(f);
              for(int i=1;i<args.length;i++)
              System.out.println("searching for \""+args[i]+"\"");
              System.out.println("found at:"+find(args[i],f));
              f.close();
    It should work, however I gave it less than five minutes testing.

  • Anyway to highlight a particular word in text?

    I'm trying to implement some necessary features using htmlText (http://livedocs.adobe.com/flex/3/html/help.html?content=textcontrols_04.html). One thing I need to do is highlight a particular word in a sentence. Something along the lines of
    This is a sentence with a <highlight> highlighted </highlight> word.
    None of the tags in the aforementioned list seem to be able to be able to do anything like this. I was hoping for a backgroundColor attribute in the font tag, or something. I've also looked at the CSS capabilities, etc... and simply using setStyle("backgroundColor" ...) wouldn't do any good, as I need to highlight only one word.
    It seems we'll just have to find another way to emphasize the text in question, but before I abandon all hope, am I missing anything?

    I think you already know this, but you can change the color of the text with <font color=""> and/or make it bold with <b>, and I think you can make it italic with <i> or <em>.
    Like I said, I think you already knew that but thought I'd mention it.
    You could use the drawing API to draw a rectangle under the word, but with different fonts and font sizes that would be difficult to get right and consistent.
    If this post answered your question or helped, please mark it as such.

  • 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]>

  • Looking for a word processor without word wrap, text edit doesn't cut it

    I'm looking for a word processor without word wrap, text edit doesn't work. In text edit, it automatically scoots my text over to the next line but I just want it to keep going with a horizontal scrollbar. Is there a text editor I can download from the app store or can I get textedit to work somehow where it uses a horizontal scroll bar instead of entering text to the next line?

    Hi,
    thought TextWrangler can do it.
    But it seems that the 'no word-wrap' "feature" isn't that much wanted anymore.
    Maybe one of these http://www.macupdate.com/find/mac/text%20editor can do it.
    Regards
    Stefan

  • PowerShell script to find a string of characters in office documents in Doc Libraries and List Item attachments?

    Hi there,
    For SharePoint 2010 site - Does someone have the PowerShell script to find a string of characters in Office/Word/Excel/PDF documents in document libraries or the ones attached to List Items?
    Thanks so much in advance.

    Hi,
    According to your description, my understanding is that you want to find some specific string character in list items using PowerShell Command.
    $w = Get-SPWeb "http://devmy131"
    $l = $w.GetList("http://devmy131/lists/fieldslist");
    $i = $l.Items[0]["Title"].ToString();
    if ($i -like '*document*')
    Write-Host "Title contains document character" $i;
    More information:
    PowerShell -contains -like
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Find exact string using formula (excel)

    I'm trying to use FIND statement to find multiple strings in the context of a larger formula. The original formula I'm basing it off of is as follows:
    =IF(ISNUMBER(FIND("INC",A1))," ","Y")
    Obviously, this yields a Y if it finds whatever text in " ". However, I have many strings for which I'd like to check and they need to be exact; ie when I search INC and inc, I do not want Inc to be counted. So, I tried the following formulas.
    =IF(ISNUMBER(FIND(OR("INC",inc"),A1))," ","Y")
    =IF(SUM(COUNTIF(A1,"* INC*","* inc*}))," ","Y")
    The second one works best, but it also counts "Inc" as a match. Any suggestions?

    bk284,
    Well you've posted to the wrong forum as this forum is dedicated to questions/issues about customizing and programming Microsoft Project, a planning and scheduling application. However, your question is simple enough that I'll just take a shot at helping.
    Try the LOWER function, it converts a text string to lower case so the upper case, lower case issue goes away.
    If this answered your question, please mark it as the answer.
    In the future, for Excel related questions, use this forum: http://social.msdn.microsoft.com/Forums/office/en-US/home?category=officedev
    John

  • Set color to a specific word in text

    I hava text in JEditorPane I want to set Color to spacific word in text
    thank you

    Engy i've been searching.U'll find EXACTLY what u want in the java tutorial ,the folder (uiswing),open the folder (Components) inside it u'll find the file(generaltext.html).there, u'll find a perfect demo with it's 2 classes TextComponentDemo.java & LimitedStyledDocument.java
    u can use them.u'll find all u want there..good luck

  • How to find a string in SAP code

    Hello,
    Does anyone here know how I can find a string inside the SAP code efficiently? I tried finding a custom table name using the Where-used list feature but the results doesn't show the complete/correct results. It missed some user exits where the table name was also used.
    Please help

    Hello Jimmy,
    You can try what Krishna has said there is one more way that is
    goto trxn SE12,
    enter Z* in the table name field,
    it will give a popup box with all the Ztables found in your system...you can find your table maybe it is a little tedious job
    Sravani

  • How to find a string inside Excel table

    Hi,
    I am trying to find a string inside Excel table, and it does not work. Please see attached figure. I use the find Invoke Node and do not get anthing.
    Please help
    Attachments:
    find_excel.JPG ‏21 KB

    See attached files.
    Thanks,
    David
    Attachments:
    Excel_table.xls ‏15 KB
    Read_XL.vi ‏42 KB

  • Office Web Apps - "Could not find trace string in ULS logs" unhealthy?

    I have reviewed everything I could find on unhealthy WAC clusters as my problem seems unrelated to certificate or missing components.  I've already digested
    http://www.wictorwilen.se/office-web-apps-server-2013---machines-are-always-reported-as-unhealthy (Thanks Wictor).
    The particular configuration is an Office Web Apps 2013 ([X-OfficeVersion, 15.0.4551.1005]), running on top of Windows Server 2012, configured for http access (SSL offloaded NLB cluster) and finally linked to Exchange 2013, Lync 2013 and SharePoint
    2013.  Everything works as expected from client side after setting IIS ARR to handle all reverse proxy bits.
    FarmOU                            :
    InternalURL                       : https://officeapps.fqdn/
    ExternalURL                       : https://officeapps.fqdn/
    AllowHTTP                         : True
    SSLOffloaded                      : True
    CertificateName                   :
    EditingEnabled                    : True
    LogLocation                       : C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS
    LogRetentionInDays                : 7
    LogVerbosity                      : Unexpected
    Proxy                             :
    CacheLocation                     : C:\ProgramData\Microsoft\OfficeWebApps\Working\d
    MaxMemoryCacheSizeInMB            : 75
    DocumentInfoCacheSize             : 5000
    CacheSizeInGB                     : 15
    ClipartEnabled                    : False
    TranslationEnabled                : False
    MaxTranslationCharacterCount      : 125000
    TranslationServiceAppId           :
    TranslationServiceAddress         :
    RenderingLocalCacheLocation       : C:\ProgramData\Microsoft\OfficeWebApps\Working\waccache
    RecycleActiveProcessCount         : 5
    AllowCEIP                         : False
    ExcelRequestDurationMax           : 300
    ExcelSessionTimeout               : 450
    ExcelWorkbookSizeMax              : 50
    ExcelPrivateBytesMax              : -1
    ExcelConnectionLifetime           : 1800
    ExcelExternalDataCacheLifetime    : 300
    ExcelAllowExternalData            : True
    ExcelWarnOnDataRefresh            : True
    OpenFromUrlEnabled                : False
    OpenFromUncEnabled                : True
    OpenFromUrlThrottlingEnabled      : True
    PicturePasteDisabled              : True
    RemovePersonalInformationFromLogs : False
    AllowHttpSecureStoreConnections   : False
    Machines                          : {WAC15PD-02, WAC15PD-01}
    The problem however is an incessant logging on the WAC cluster nodes of event 1204,2204 followed almost immediately by 1004,2004.  This repeats every 4min or so...
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider
    Name="Office Web Apps Monitoring" />
      <EventID
    Qualifiers="0">1204</EventID>
      <Level>2</Level>
      <Task>1</Task>
      <Keywords>0x80000000000000</Keywords>
      <TimeCreated
    SystemTime="2014-02-04T20:49:37.000000000Z" />
      <EventRecordID>3043246</EventRecordID>
      <Channel>Microsoft Office Web Apps</Channel>
      <Computer>wac15pd-01.fqdn</Computer>
      <Security
    />
      </System>
    - <EventData>
      <Data><?xml version="1.0" encoding="utf-16"?> <HealthReport xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <HealthMessage>UlsControllerWatchdog reported status for UlsController in category 'Verify Trace Logging'. Reported status: Could not find trace string in ULS logs in C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS.</HealthMessage>
    <ComponentOwner>ServicesInfrastructure</ComponentOwner>
    </HealthReport></Data>
      </EventData>
     </Event>
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider
    Name="Office Web Apps Monitoring" />
      <EventID
    Qualifiers="0">2204</EventID>
      <Level>2</Level>
      <Task>1</Task>
      <Keywords>0x80000000000000</Keywords>
      <TimeCreated
    SystemTime="2014-02-04T20:49:37.000000000Z" />
      <EventRecordID>3043247</EventRecordID>
      <Channel>Microsoft Office Web Apps</Channel>
      <Computer>wac15pd-01.fqdn</Computer>
      <Security
    />
      </System>
    - <EventData>
      <Data><?xml version="1.0" encoding="utf-16"?> <HealthReport xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <HealthMessage>UlsControllerWatchdog reported status for UlsController in category 'Verify Trace Logging'. Reported status: Could not find trace string in ULS logs in
    C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS.</HealthMessage> <ComponentOwner>ServicesInfrastructure</ComponentOwner>
    </HealthReport></Data>
      </EventData>
      </Event>
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider
    Name="Office Web Apps Monitoring" />
      <EventID
    Qualifiers="0">1004</EventID>
      <Level>2</Level>
      <Task>10002</Task>
      <Keywords>0x80000000000000</Keywords>
      <TimeCreated
    SystemTime="2014-02-04T20:49:39.000000000Z" />
      <EventRecordID>3043266</EventRecordID>
      <Channel>Microsoft Office Web Apps</Channel>
      <Computer>wac15pd-01.fqdn</Computer>
      <Security
    />
      </System>
    - <EventData>
      <Data><?xml version="1.0" encoding="utf-16"?> <HealthReport xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <HealthMessage>AgentManagerWatchdog reported status for
    AgentManagerWatchdog in category 'Recent Watchdog Reports'. Reported status: Machine health is Unhealthy</HealthMessage> </HealthReport></Data>
      </EventData>
     </Event>
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider
    Name="Office Web Apps Monitoring" />
      <EventID
    Qualifiers="0">2004</EventID>
      <Level>2</Level>
      <Task>10002</Task>
      <Keywords>0x80000000000000</Keywords>
      <TimeCreated
    SystemTime="2014-02-04T20:49:39.000000000Z" />
      <EventRecordID>3043267</EventRecordID>
      <Channel>Microsoft Office Web Apps</Channel>
      <Computer>wac15pd-01.fqdn</Computer>
      <Security
    />
      </System>
    - <EventData>
      <Data><?xml version="1.0" encoding="utf-16"?> <HealthReport xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <HealthMessage>AgentManagerWatchdog reported status for
    AgentManagerWatchdog in category 'Recent Watchdog Reports'. Reported status: Machine health is Unhealthy</HealthMessage> </HealthReport></Data>
      </EventData>
      </Event>
    Further exploration of ULS log files (C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS) did not yield particularly much, except the following;
    02/04/2014 20:48:04.48  UlsControllerWatchdog.exe (0x1244)       0x0F60 Services Infrastructure        Uls Controller Watchdog        ajbam Assert 
     We're about to trace a string for category MsoSpUlsControllerWatchdog at level Info and we expect to find in the log later, but it appears that the category has been throttled. We will never be able to find the string and this watchdog will always fail.
    StackTrace:   at Microsoft.Office.Web.UlsControllerWatchdog.Program.CheckServiceInstance(ServiceInstance serviceInstance)     at Microsoft.Office.Web.Common.WatchdogHelperThreadManager.GetHealthResults(WatchdogExecutionContext
    context, ServiceInstance si)     at Microsoft.Office.Web.Common.WatchdogHelperThreadManager.WatchingThreadMethod(Object o)     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback
    callback, Object state, Boolean preserveSyncCtx)     at System.Threading.ExecutionContext.Ru... 345fbec5-e958-4f1f-bf56-d65c1c0d472a
    02/04/2014 20:48:04.48* UlsControllerWatchdog.exe (0x1244)       0x0F60 Services Infrastructure        Uls Controller Watchdog        ajbam Assert 
     ...n(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)     at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()    
    at System.Threading.ThreadPoolWorkQueue.Dispatch()   345fbec5-e958-4f1f-bf56-d65c1c0d472a
    02/04/2014 20:48:05.52  UlsControllerWatchdog.exe (0x1244)       0x0F60 Services Infrastructure        Services Infrastructure Health adhog Unexpected Health report
    by UlsControllerWatchdog: Agent: UlsController, eventId: 1204, eventType: Error, categoryId: 1, eventMessage: <?xml version="1.0" encoding="utf-16"?>  <HealthReport xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <HealthMessage>UlsControllerWatchdog reported status for UlsController in category 'Verify Trace Logging'. Reported
    status: Could not find trace string in ULS logs in C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS.</HealthMessage>    <ComponentOwner>ServicesInfrastructure</ComponentOwner>  </HealthReport> 345fbec5-e958-4f1f-bf56-d65c1c0d472a
    02/04/2014 20:48:05.52  UlsControllerWatchdog.exe (0x1244)       0x0F60 Services Infrastructure        Services Infrastructure Health adhoh Unexpected Health report
    by UlsControllerWatchdog (persistent): Agent: UlsController, eventId: 2204, eventType: Error, categoryId: 1 345fbec5-e958-4f1f-bf56-d65c1c0d472a
    I suspect these might be related, but can't seem to find any logical explanation why this should cause the Get-OfficeWebAppsMachine to report HealthStatus of Unhealthy.  If related, is there a way to disable this check or remove throttling in a safe
    way?  Alternatively if this is some coding issue (I've not found any other blog/QA dealing with this particularly) it would be nice to get confirmation of this and potentially a fix/solution.
    Any help would be greatly appreciated. Thank you!

    Hi ChristiaanB,
    You get this ULS error because you change the log verbosity of the OWA farm. I wrote an article for this on my blog : OWA unhealthy uls issue
    Regards,
    Wes

  • How to find out the stop words of an index?

    I am sure it's something very easy but:
    I want to find out the stop words that i am using in a particular index via SQL query?
    I had several indexes with diferent stoplists.
    Thanks

    I already found out.
    thanks.
    for anyone also looking see
    select * from ctx_stopwords;

Maybe you are looking for