Search and Replace help. Please

I have imported some text where in the original there is italic content but when bringing into IDCS4 that italic text shows up as _italic words_. That is as roman with _ characters surrounding it. Is there a way to search and replace. Needless to say the text between the _s varies.

I would try a GREP find/change searching for (_)([^_]+)(_) and replace with $2 Set the change formatting to italics (preferably as a character style).  This translates to look for a _, then anything that is not a _, followed by another _, and replace with only the stuff in between. You can also use (_)(.+?)(_) which would match the shortest srting in between two _ characters in the same way (except it won't cross a paragraph break), but it will run a bit slower.
Credit for this should go to Peter Kahrel and his excellent GREP primer....

Similar Messages

  • Help with search and replace script please

    Hi all
    I've written a javascript which uses various GREP and text find/changes to copy some text from the first two paragraphs of a document and use them elsewhere (in the running head and footers) and now I want to delete the first two paragraphs. Not sure how I would do that. If I was doing a manual find/change (with nothing selected) it would automatically select the first para in the first text box but when I run teh following;
    app.findGrepPreferences.findWhat = "^.+$";
    app.changeGrepPreferences.changeTo="";
    app.activeDocument.changeGrep();
    it finds all paragraphs and deletes them. I was going to include the code twice; once to delete the first paragraph and then again to delete the other (new first) paragraph. My JS skills are shaky but I'm quite comfortable with GREP. Can anyone point me in the right direction for how I acheive what I want? If I did a for loop surely I'd just be doing the same thing but more than once!
    Much to my surprise the rest of the script is working although it made my brain hurt!
    thanks for any suggestions,
    Iain

    Oooh. After
    myStory=app.activeDocument.stories.everyItem();
    the variable "myStory" won't point to just a single story, but ... to "every story". So that's why the next line removes more than you intended!
    What the "everyItem" thingy internally does is still unclear to me, but that doesn't keep me from using it -- but only when you absolutely, positively want to perform an action on every item
    Now the usual examples say something like
    myStory = app.activeDocument.stories.item(0); // access first story
    but that's No Good. Even if your first story is the one you are targeting today, tomorrow, in a different document, it'll be story #1, or #5, or #255. There is no general rule that states the first story is always the largest one, or something like that.
    If this is going to be used with a document template, the best way to identify the target story is by giving the first text frame a unique label. Otherwise, you'll have to think of something else ... A couple of other strategies:
    1. You are already using GREP to find stuff. If one of those searches is guaranteed to return just text in the one story you are interested in, you can use this.
    2. You mention headers and footers. If your main text is the only one that runs through multiple text frames, you can loop over all stories and check which one runs through than a single text frame.
    3. ... (I'm pretty sure there are some more strategies ...)

  • How do I search and replace in comments in Acrobat XI?

    I use a Mac and just downloaded Acrobat Pro XI specifically to search and replace phrases in comments in a large PDF. According to this Adobe Help page, I should be able to do this: https://helpx.adobe.com/acrobat/using/searching-pdfs.html I copied the relevant section below and marked with ***. However, I don't see I don't see an arrow for the options that would allow me to include comments. I understand how to include the comments with advanced search, but I want to also replace text. I also checked in preferences and searched the forums. Could someone please advise and maybe include a screenshot, if possible. Thanks!
    Choose Edit > Find (Ctrl/Command+F). 
    Type the text you want to search for in the text box on the Find toolbar. 
    To replace text, click Replace With to expand the toolbar, then type the replacement text in theReplace With text box. 
    (Optional) Click ***the arrow ***next to the text box and choose one or more of the following: 
    Whole Words Only 
    Finds only occurrences of the complete word you type in the text box. For example, if you search for the word stick, the words tick and sticky aren’t found.
    Case-Sensitive
    Finds only occurrences of the words that match the capitalization you type. For example, if you search for the word Web, the words web and WEB aren’t found.
    Include Bookmarks
    Also searches the text in the Bookmarks panel.
    ***Include Comments***
    Also searches the text of any comments.

    Here are screenshot of my attempts to make reducing double returns to one. First up selection of a double return:
    Copy to the clipboard. Do a Command-F. Here's the resulting dialogue:
    I paste in the contents of the clipboard:
    Note the Search field no longer has an empty slot selected. Something is clearly in there, but no instance of whatever is has been found. Nevertheless, I proceed to set up the Replace field by selecting a single return:
    Copy that to the clipboard and paste into the Replace field:
    Nothing to search for and therefore nothing to replace. Am now wondering what that little scoop to the right of the eyeglass icon might indicate. Clicking on it reveals this:
    Definitely not "a solution that just works."

  • Search and replace string problems

    Hi to all,
    I have problem with Search and replace string function. It shows me a wrong Value (Number) from 15 to 100 is everything OK (15=0, 30=1, 45=2, 100=3), but after 100 ........
    Take look in VI and if you have any ideas post them please
    THX
    Igor 
    Attachments:
    indexing.vi ‏10 KB

    there will be no 15115 string, but 15 or 115 and 15 is 0, 115 is 4. Anyway, i have changed string input format and now its working THX for your help
    Attachments:
    indexing.vi ‏10 KB

  • JS InDesign Server CS2 - Search and Replace

    I am struggling to get a search and replace script to work on InDesign Server CS2.
    This works on my Desktop CS2:
    app.documents[0].search('xxx', false, false, 'yyy');
    but not through InDesign Server CS2.
    Can any one please help.
    Thanks
    Simon Kemp

    Thanks for all of the replies.
    This situation is that the company I work for has decided to consolidate some of the duties of our graphics departments.  People in one location will be dummying documents for people at another location.
    The paths to the images are UNC paths, which means they're pointing to different shares on different servers.  This cannot be changed.
    Also, the images at either location may not exist until days after the dumming process.
    During the dummying process, the application that's used to build the pages places empty ad boxes (placeholders) on the page.  The placeholders are text frames.
    I don't understand in what way, but the paths to the images are hidden inside the InDesign file.  From the users' standpoint, the placeholders simply display basic information about the ad (customer name, ad number, etc.) and hold the position for the images that will be placed later.
    It is not using script labels to apply the paths.
    So, this is why I describe the problem as needing to do a search and replace inside the InDesign file.
    As I mentioned before, I know this is doable.  I think I now see that the problem problem is figuring out how these hidden paths are being applied in the document.  My only thought was script labels, but this is not the case...

  • How to search and replace in an xml file using java

    Hi all,
    I am new to java and Xml Programming.
    I have to search and replace a value Suresh with some other name in the below xml file.
    Any help of code in java it is of great help,and its very urgent.
    I am using java swings for generating two text boxes and a button but i am not able to search in the xml file thru the values that are entered into these text boxes.
    Thanks in advance.
    **XML File*
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <student>
    <stud_name>Suresh</stud_name>
    <stud_age>40</stud_age>
    </student>Also i am using SAX Parser in the java program
    any help of code or any tutorials for sax parisng is very urgent please help me to resolve this problem
    Edited by: Karthik84 on Aug 19, 2008 1:45 AM
    Edited by: Karthik84 on Aug 19, 2008 3:15 AM

    Using XPath to locate the elements you are after is very easy.
    Try something like this:
    import java.io.File;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    public class BasicXMLReplaceWithDOM4J {
         static String inputFile = "C:/student.xml";
         static String outputFile = "C:/studentRenamed.xml";
         public static void main(String[] args) throws Exception {
              // Read xml and build a DOM document
              Document doc = DocumentBuilderFactory.newInstance()
                        .newDocumentBuilder().parse(new InputSource(inputFile));
              // Use XPath to find all nodes where student is named 'Suresh'
              XPath xpath = XPathFactory.newInstance().newXPath();
              NodeList nodes = (NodeList)xpath
                   .evaluate("//stud_name[text()='Suresh']", doc, XPathConstants.NODESET);
              // Rename these nodes
              for (int idx = 0; idx < nodes.getLength(); idx++) {
                   nodes.item(idx).setTextContent("Suresh-Renamed");
              // Write the DOM document to the file
              Transformer xformer = TransformerFactory.newInstance().newTransformer();
              xformer.transform(new DOMSource(doc), new StreamResult(new File(outputFile)));
    }- Roy

  • Search and replace with comma

    Hello All,
    I want some help. Please help me.
    I have comma delimited Data. When I’m converting Sting to Array, If two commas exists in between then its displaying “Zero” (because its array propriety ). Instead of that I want to display “NaN” .
    Please give me any idea to replace comma to NaN. I tried with Search and Replace but it’s not giving as I expected.
    Munna
    Solved!
    Go to Solution.

    Hello GerdW,
    Thanks you so much for your reply.
    I thought, instead of replacing trailing comma by NaN adding comma before string is more better (because to many string manipulations) But, it’s taking more execution time.
    Munna
    Attachments:
    Search and Replace.vi ‏415 KB

  • Catalog manger "search and replace " using xml script

    Hi ,
    we have renamed 6 rpd columns names in rpd & alias is not removed yet .In catalog manager i can search and replace using string .But it takes lot time as they are stored in different reports , which are existing . I am trying to use xml script for replacing them.I got sample script from help file for single column . can anyone help for doing that for multiple strings.I will provide with my inputs .
    my inputs:
    <?xml version="1.0" encoding="utf-8"?>
    <actions>
    <action command="textReplace" oldValue="column 1 " newValue="column one" ignoreCase="true"/>
    <action command="textReplace" oldValue="column 2" newValue="column two" ignoreCase="true"/>
    <action command="textReplace" oldValue="column 3" newValue="column three" ignoreCase="true"/>
    </actions>
    please correct me .

    Given xml content looks okay but just in case check this oldValue="column 1 ", there is additional space at the end.
    I would suggest to extract Analysis report (.csv) using Catalog Manager and find out the list of reports based on those columns.
    This would help you learn with list of reports based on report owners, and then go for the fixing those reports.
    If you go by xml replace you never know the affected reports and you may not confirm until report owners come back to you with issues.
    This might take little bit time but your changes based on proper doc.
    Let me know updates, if helps mark
    Edited by: Srini VEERAVALLI on Feb 19, 2013 3:21 PM

  • Using a variable in a Powershell search and replace string

    Hi
    a couple of days ago I posted a question about doing a search and replace with wildcards
    Search and repalce with Widcards
    I got a swift and very helpful answer but now I need to build on it.
    In a text file I wanted to replace all the text between two defined words.  the script I got was this
    $text = 'Some Server this bit of text varies Language stuff'
    $text -replace '(.*Server) .+? (Language.*)','$1 it will always say this $2'
    It works great but now I want to replace "it will always say this" with a variable and I can't figure out the correct grammar to make this happen.
    Can anyone help??
    Thanks
    Alex

    Here's one way:
    $replace = 'it will aways say this'if ( $text -match '(.*Server) .+? (Language.*)' )
    { "{0} $Replace {1}" -f $matches[1,2] }
    else { $text }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • HTML character entities problem in saved regex search and replace query

    I have a many search and replace regular expression queries (.dwr files) that I have saved. I have a problem specifically with saved queries that contain HTML entities such as "& nbsp ; " or "& shy ;" (spaces added otherwise code doesn't render in browser). For example if I use the following search:
    ([\d]{3}& shy ;[\d]{3}& shy ;[\d]{4}|[\d]{3}& nbsp ;[\d]{3}& nbsp ;[\d]{4})
    (which searches for numbers in the 888-555-1234 or 888 555 1234 formats)
    This will work fine if I manually enter it into the search text area. However if I save it to file and reload it, it will no longer work because the &shy; and   characters are now displayed as " " (space) and "-"(shy) rendering the saved query useless as it's no longer searching for the code. I have some fairly long and complex queries and this is becoming a problem.
    Thanks for any help.
    I'm currently using Dreaweaver CS4 at home and CS5.5 at work.

    Thanks for your reply Kenneth, but that is not what I'm trying to accomplish. I'm looking for the HTML entities that exist in the source code which are & shy ; and & nbsp ; (without the spaces). As I mentioned above, if I enter them manually in the search box, I will get the corrrect results. If I save the search and then reload it, the special characters are no longer in HTML and the search is now useless.
    Just for example again
    In an open document in code view insert a number in the format (without the spaces): 888& nbsp;888& nbsp ;8888
    Open a search dialog box and enter (without the spaces): [\d]{3}& nbsp ;[\d]{3}& nbsp ;[\d]{4}
    The search will find that entry.
    Save search as phone.dwr for example. Then load it and try the search again. It won't work because upon loading the search Dreamweaver replaces the HTML code which was saved with the rendered HTML. So now the search shows up as: [\d]{3} [\d]{3} [\d]{4} which will not find the string with hard coded non-breaking spaces that I'm looking for.
    Basically I want to be able to save a search query for reuse. When I load a search query, I want it to be exactly what I saved, not something that DW has rendered (that doesn't work).

  • Search and replace in a applet

    Hello,
    I have a string "jds" that looks like this
    http://ns2.taproot.bz/thumbs2/1.jpg
    I have been using this to replace "thumbs2" with "big" and create a url
    URL my_thumb = new URL(jds.replaceAll("thumbs2", "big"));however now that im making this code into a applet, this no longer
    works. Could some one please suggest a way around this.
    Thanks,
    jd

    replaceAll method in String is available only from 1.4 onwards.
    http://java.sun.com/j2se/1.4.1/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String).
    You could use a method to search and replace a String with another...
    public String replace (String source, String search, String replace) {
        StringBuffer result = new StringBuffer();
        int start = 0;
        int index = 0;
        while ((index = source.indexOf(search, start)) >= 0) {
          result.append(source.substring(start, index));
          result.append(replace);
          start = index + search.length();
        result.append(source.substring(start));
        return result.toString();
    }

  • How to get numeric result from 'search and replace' string function

    hii
    i am using search and replace function to get output.my output is of form ' *X0123.3 ' .here i am replacing the term *X01 with space because i need only 23.3 as a result.but i am unable to get that out in the output indicator.i used lot of functions like string to number and so on but i am getting output as zero .can you please suggest me wt to do.i am attaching a copy of my file.
    Attachments:
    Untitled 1.vi ‏25 KB

    Your problem is the fact that you are converting it to an integer, thus loosing the fractional part. You need to use "Fract/Exp String To Number" instead and create a DBL so yor data is 23.3 instead of 23.
    You also don't need to manipulate the string if the initial part is of constant lenght. Just use the offset input as in the figure below.
    Message Edited by altenbach on 07-31-2006 07:02 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ToDBL.png ‏2 KB

  • Bug in Multi-File Search and Replace in RH6?

    I'm using the 6.0 trial, and one thing I want to be able to
    do is to replace the variables I put in using JavaScript with the
    new feature variables in 6.0. So, I went in to multi-file search
    and replace, and searched for:
    <script
    language=JavaScript>document.write(varProduct)</script>
    I copied this code directly from a topic, and pasted it into
    the Search tool.
    I don't even care whether I can successfully copy the code
    from my new variable for use as the replacement text; I'd be happy
    if the multi-file search would simply find all occurrences of my
    original code so I don't miss any during conversion to 6.0.
    It keeps coming up as not found, and this concerns me
    greatly. Has anyone else experienced this? Is it a known bug? Does
    anyone have a workaround?
    Thanks!

    Hi robowriter
    I'm assuming you are using the wondrous little applet known
    as Multi-File Find and Replace.
    Unfortunately, this little beastie is like a cat. It
    frequently has a fussy tummy and loves to hork up furballs. Well,
    not exactly. Really what it does is fail to properly handle
    anything with a line break. So you need a tool that does do this.
    Fortunately, one exists! It is called FAR (Find And Replace). Oddly
    enough, it was also written by a fellow Microsoft Help MVP named
    Rob Chandler. (Rob lives in Australia)
    You can download a trial version of FAR from the FAR page.
    Click here to visit
    the FAR page
    Cheers... Rick

  • Search and replace string function

    Hello, I am using the "search and replace string" function and it does nt seem to work consistently for me.   I am using it in a situation where I am taking an array of strings, converting this into a spreadsheet string then deleting all of the commas.  Has anyone experienced the same behavior? I have searched through other posts and found other simular faults but none of the fixes worked for this. I can post the code it needed.
    Thanks,
    Andrew

    I agree that commas are often not desirable, especially if your software should also work in countries where comma is used as a decimal seperator.
    Where are the commas coming from? Does (1) each element of the original array have one (or more), do you (2) use comma as seperator if you convert it to a spreadhseet string?
    For (1), you might just strip out the comma for each element right in the loop. For case (2) you would simply use a different separator to begin with, of course.
    Btw: you are abusing a WHILE loop as a FOR loop, because you have a fixed number of iterations. Please replace it with a FOR loop. If you use a FOR loop, LabVIEW can manage memory much more efficiently, because it can allocate the entire output array before the loop starts. For While loops, the total number of iterations is not known to the compiler. (Of course a real program would also stop the loop if an error occurs. In this case you would need to stay woth the WHILE loop. )
    Do you have a simple example how the raw array elements look like. How many commas are there?
    LabVIEW Champion . Do more with less code and in less time .

  • How can I search and replace fonts?

    iOS 7 doesn't support the Adobe workhorse fonts I've most relied on for years, and arbitrarily changes them to iOS built-in fonts when I link my standard documents and templates to the iPhone, via iCloud. There's no apparent logic to how it does this; a Pages document in Minion Pro, a serif font, gets changed to the sans-serif Helvetica. Myriad Pro may come out in Times New Roman. I accept that the iPhone's limited number of fonts makes translation necessary, but does Pages offer a way in which I can search and replace inappropriately substituted fonts for more logical alternatives?

    You noticed the first one yourself: the Found item list seems to randomly jump around the document -- I believe you are correct in your observation it may be due to the object construction order. That tells me, by the way, something about your lot numbers that tou didn't mention: your text is not one continuous long threaded story, but it's all or partially in disconnected etxt frames. The Found list does return everything inside a single story in the correct order, but it goes over each separate story in the order they were constructed.
    The only solution is to gather all of your lot numbers, *re-sort* them according to the page number they appear on (and some sort of Worst Case Scenario is when you might have more than one lot number frame per page; in that case you also need to sort by textframe, top to bottom -- yet even worse is if you also may have these textframes side by side!).
    Only then you have a reliable counting order.
    This isn't too bad. We can just extend the method I offered for sorting top-to-bottom/left-to-right in Re: Working around the frame selection order issue in CS 4 and make it also include page numbers:
    function byPageYX(a,b) {
        var
            aP = a.parentTextFrames[0].parentPage.index,
            bP = b.parentTextFrames[0].parentPage.index,
            aY = a.baseline[0],
            bY = b.baseline[0],
            aX = a.horizontalOffset[1],
            bX = b.horizontalOffset[1],
            dP = aP-bP,
            dy = aY-bY,
            dx = aX-bX;
        return dP?dP:(dy?dy:dx);
    myResults.sort(byPageYX);
    Or something like that.
    As for actually implementing the above I cannot be of any help with Applescript.
    Once we're dealing with sorting I think you're much better off in Javascript anyhow.

Maybe you are looking for