Search and Replace using wild characters

I have a bit of a problem on my hands while dealing jdom and xml. I am parseing an xml response from a service. The issue is that it contains an element with a colon. Nothing I can do about the service so I have to deal with it. I know I could use DOM and s on but I have chose to use jdom for a couple of reasons. What I am planning on doing is removing the colon in the element names with some sort of search and replace. The problem is that the there could be up to 500 element names with a numeric value. The element name looks like the following ns1:Point, ns2:Point, ns3:Point, and so on. JDom will not handle this so I would like it the element name to look ns1Point, ns2Point, etc. I have the xml returned from the service in a string. Is there any way I can do a search and replace given the above information. Thanks in advance

Silverfoot wrote:
I realize that it seperates the name space. The namespace for the element is different than ns1. Maybe I am missing something though
Using JDOM, I navigate my way through the xml using getChild(elementname, namespace). When i get to ns1:Point, i use the same namespace as previous elements. Are you suggesting that ns1 is another namespace. In that case I would use a second name space to the Point element.I think you're missing a whole lot, actually. You don't seem to know much about namespaces. For a start you're apparently making the beginner error of assuming that the namespace prefix declares the namespace. And this idea:
What I am planning on doing is removing the colon in the element names with some sort of search and just wrong. I would suggest you go off and find a tutorial (or a chapter in your XML book) about namespaces.

Similar Messages

  • 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"?>
    <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"/>
    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

  • GUI Based tool for search and replace using regular expression

    I have developed this small tool which can be used for search and replace in multiple files using reqular expressions.
    1. Full regular expression
    2. GUI based with Highlighted results
    3. Preview for replace available
    4. Pure Java based.
    5. Its like unix sed and grep
    Please visit below site for download/more information :
    Hitesh Viseria

    I agree with you, it cannot compete grep/sed/awk combination. I couldnt find anything even close to grep/sed for windows which will also have a preview and most important, free. That is what made me write this tool. I am trying to
    improve its performance and more features like history etc.
    Any suggestions on additional features are most welcome.

  • Search and replace for Unicode characters

    I have a function which searches and replaces characters on file. It works with ASCI sharacters, but not when the strings which needs to be replaced contains Unicode ('á', 'ā') etc.  The source file is codding
    utf8 .
    $file = "file.txt" 
    $SearchReplace = @($file)
    #Process files by performing a search and replace
    foreach ($file in $SearchReplace) 
    #Select-Object -Skip 1 |
        (Get-Content $file) | 
            Foreach-object { $_ -replace 'unicode_string' , ';'   } | 
         out-file -encoding Unicode $file
    How to get working the search (and replace) function with Unicode characters?

    No. it does not. I have verified that script does not recognize the diacritic
    'ā') characters when at all the operations with the files I have specified encoding utf-8/Unicode.

  • Case insensitive search and replace using ASP and Oracle database

    I am interested in providing a case insensitive search and replace query in a Active server page. At present data is collected from a html form which passes the text values to a ASP page. The ASP page runs a search (select query) to find if the data is already in the Oracle database, if it isn't the ASP page runs sql (INSERT) to insert the record, if not the page returns a form indicating that the record already exists. At present we can convert the case of new records using the VB UCase() function. But can't do a insensitive search with the existing records. *The Query must be able to utilize ASP variables.
    Any help would be much appreciated.
    David Cheryk

    I can't check your script right now since I'm not on Mac. I recommend you to use FindChangeByList script for CS4 instead (it works with CS3): together with Martin Fisher's:
    Use this script to record settings from Text and GREP tabs, then copy and paste them into FindChandgeList.txt file.
    Or, optionally you can use this script:

  • Multi search and replace using excel file

    I am trying to use a script to open multiple indesign files and perform several find and replaces using a delimited word file containing the searches, this script, plagerised from a quark one, opens files but doesnt S&R, can anybody see the error of my ways?
    -- Indesign docs
    set QFolder to "Please locate the folder containing your Indesign documents..."
    set Doc_Folder to (choose folder with prompt QFolder) as text
    set theFiles to {}
    tell application "Finder"
    tell folder Doc_Folder
    repeat with i from 1 to count of files
    if file type of file i is "IDd5" then
    set end of theFiles to file i as text
    end if
    end repeat
    end tell
    end tell
    -- Search Items
    set QFile to "Please locate your Tab Delimited Text file..."
    set Search_File to (choose file with prompt QFile) as text
    set Search_Rows to read file Search_File using delimiter {return}
    set Search_Items to {}
    repeat with This_Row in Search_Rows
    set end of Search_Items to my GetTextItem(This_Row as text, tab, 0)
    end repeat
    tell application "Adobe InDesign CS3"
    --Clear the find/change preferences.
    repeat with oneFile in theFiles
    open file oneFile
    set find text preferences to nothing
    set change text preferences to nothing
    --Set the find options.
    set case sensitive of find change text options to true
    set include footnotes of find change text options to true
    set include hidden layers of find change text options to false
    set include locked layers for find of find change text options to true
    set include locked stories for find of find change text options to true
    set include master pages of find change text options to true
    set whole word of find change text options to true
    tell document 1
    repeat with ThisPair in Search_Items
    set {searchstring, replaceString} to ThisPair as list
    tell every story
    set (every text where it is searchstring) to replaceString
    end try
    end tell
    end repeat
    end tell
    close document 1 saving yes
    end repeat
    end tell
    on GetTextItem(ThisString, ThisDelim, ThisItem)
    -- ThisString -> String to look in
    -- ThisDelim -> Text element that delimit the string
    -- ThisItem -> Number of the element to return (0 for all)
    copy the text item delimiters to OldDelims
    set the text item delimiters to ThisDelim
    if class of ThisItem is list then
    set fromItem to (item 1 of ThisItem) as integer
    set toitem to (item 2 of ThisItem) as integer
    set arrItem to (text items fromItem thru toitem of ThisString)
    set arrItem to every text item of ThisString
    end if
    set the text item delimiters to OldDelims
    if class of ThisItem is list then
    return arrItem as text
    if ThisItem is not equal to 0 then
    return (item ThisItem of arrItem) as text
    return arrItem -- return every items
    end if
    end if
    end GetTextItem

    I can't check your script right now since I'm not on Mac. I recommend you to use FindChangeByList script for CS4 instead (it works with CS3): together with Martin Fisher's:
    Use this script to record settings from Text and GREP tabs, then copy and paste them into FindChandgeList.txt file.
    Or, optionally you can use this script:

  • Joker characters in the search and replace function

    Hello everyone,
    Just a quick question :
    I was wondering what character can be used as a joker character in the search and replace function (I did a research in the site, but didn't find any thread)
    To be clear, I have misspelled a word, for example «trouser».
    I know I didn't make any mistake with the first and last letter, but sometimes I wrote it «tourser», «turoser»
    (sorry if there is a weird meaning, i'm french, and for me it won't mean anything, so don't take it personally)
    I would like to be able te replace all the versions of «trouser», even the good ones, using «t*****r» in the search and replace function.
    I tried the «*» character, but it's not the jocker.
    Thank you for your help !

    As I can't edit my first message, just wanted to let you know it's also called «wildcard» characters
    Like here (Careful, it's… Ms Office)

  • Global Search and Replace for Scrambled/Garbled Characters

    So I exported a bunch (over 3000) contacts from my Outlook on Windows by using Outlook2Mac, and also tried just using a straight CSV export. But the Chinese characters came out all garbled, and I no longer have the use of that Windows machine anymore.
    Here's an example:
    Name: ∂¿¨¸™K (May Huang)
    Job Title: ±M§·∏g≤z
    Dept: ¿Á∑~≥B/ODM∑~∞»≥°
    Company: ®Ù•fl∞ͪ⁄
    I figure I can slowly piece together most of it by doing lots of global search and replaces -- for instance, "•x∆W" should be "台灣" (Taiwan) -- and changing each characters I know one by one.
    Problem is, I can't figure out how to do a find and replace! Can anyone help me out?
    Thanks in advance!
    PowerBook G4 17   Mac OS X (10.4.5)  

    But for the sake of getting a solution to the
    original problem, I wasn't able to export the vCards
    from AddressBook and then do what you said. For some
    reason, I couldn't open the .vcf file in TextEdit;
    kept telling me that the file wasn't encoded in
    "Traditional Chinese (Windows, DOS)" format.
    You need to use the Open dialogue in TextEdit and open the .vcf in something that it will accept. When you export the stuff from Address book, it indeed is not in Trad Chinese.
    I don't have your stuff, so I can't be exactly sure, but it should work something like this. You export everything from Address Book. Use the Open dialogue of TextEdit to open the file, probably as UTF-8. Save as MacRoman. Open again as Trad Chinese (Windows). Save as UTF-8. Reimport. You may need to experiment to find what works right.

  • 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>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 javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    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++) {
              // Write the DOM document to the file
              Transformer xformer = TransformerFactory.newInstance().newTransformer();
              xformer.transform(new DOMSource(doc), new StreamResult(new File(outputFile)));
    }- Roy

  • In Pages, how to search and replace text involving invisible characters?

    In Pages documents, how to search and replace text involving invisible characters, colors and font sizes—a task which is so easy in Mircosoft Word?

    I read that an older version of Pages allowed users to enter special characters in the search/replace fields, but this did not work for me.
    I still am looking for a way to do this.

  • Regular expression to change Hour:Min:Sec time to Min:Sec using the Search and Replace tool

    I think the title says it all, but I've used a script to export a project from an NLE as a html file with a bunch of images and timecodes within table cells. For example, In=00:00:34 and Out=00:01:30 needs to be converted In=0:34 and Out=1:30. I think the Search and Replace is the most simple way of working that, but I've not experience with Regular Expressions (or much in that regard) so would really appreciate if someone could give me a hand writing the Regular Expression I need to achieve this.
    Thanks in advance,

    Okay, so an example row is:
    <td align="left" valign="top"><p align="left"><img src="Snapshot At Event Start [00-01-22-19].jpg"><br>
    <strong>In: </strong>1:22<br>
    <td align="left" valign="top"><p align="left"><img src="Snapshot At Event End [00-01-24-25].jpg"><br>
    <strong>Out: </strong>1:24<br>
    <td width="100%" align="left" valign="top"><p><strong>Cut to League Video</strong></p>
      <p><strong>Duration</strong>: 2<br>
    I need to change it to:
    <td align="left" valign="top"><p align="left"><img src="Snapshot At Event Start [00-01-22-19].jpg"><br>
    <strong>In: </strong>1:22 seconds<br>
    <td align="left" valign="top"><p align="left"><img src="Snapshot At Event End [00-01-24-25].jpg"><br>
    <strong>Out: </strong>1:24 seconds<br>
    <td width="100%" align="left" valign="top"><p><strong>Cut to League Video</strong></p>
      <p><strong>Duration:</strong> 2 seconds<br>
    The script itself is something I found somewhere on the internet - it's for Sony Vegas.
    I've highlighted the changes with bold underlined italics.
    Thanks for you help, guys,

  • Using a variable in a Powershell search and replace string

    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??

    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 " "

  • Search and Replace... tried everything, no luck, think it's quite simple!

    Hi Guys,
    I'm trying to do  some editing on many many html files. As it wouldn't be realistic in the slightest to do it manually I'm trying to use the search and replace feature in DW, but it's proving quite difficult. I've looked at everything available on this forum and others with no luck.
    So I'm trying to replace a huge block of code, but as the code is different in all the files I have to use the wildcard. So I match up the code at the front and the block which is the same in all the files I'm trying to change and insert [^"]*. For example, if I wanted to change the meta content  I search for:
    <meta name="description" content="[^"]*" />
    It doesn't find it.
    The other blocks of code are much bigger and it's the same story. If I copy the code in which I am looking to replace (without the wild card) and search it doesn't find it, but if I click off 'use regular expression' it does find it, so this leads me to believe that it may be something to do with the special characters that is in the code that I am trying to replace, but I am unsure how to go about excluding these..
    Any help much appreciated,

    I'm the very first to admit that I STINK at Reg Ex.  It's a totally foreign language to me. 
    Whenever possible, I use the Search Tag with Attributes feature.
    So let's say you need to find all meta tags that contain attribute "name" & the content is different in each one.
    Find In: Current document (to test)
    Search: Specific Tag         meta
    With Attribute                      name = [any value]
    Action:  Set Attribute          content   to: type your new values here....
    Replace All.
    Hope this helps. 
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists

  • 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).

  • Find and Replace using Wildcards

    I am following the procedure outlined in Trent’s Blog: l
    This is fantastic stuff and will really help me.
    I have a few (but only a few) times had success.
    It says to “Use regular expression.”  What does that mean?  What is an “irregular expression?”  I have tried with the box checked and unchecked.  Usually with the box checked it will not Find my string.  I uncheck the box and it sometimes does.
    Link to
    At the moment all the Cases are identical.  I have not uploaded the .css to the site so the right-most formating is not properly displaying.  It does work when the .css is available.
    In the source code I literally copy the line of code:
    <p class="type_X"><u>Joh. Heinrich Sch&ouml;m (1713-1785) <span  class="right-most">1.</span></u></p>
    and paste it into the Find box of F&R.  I then put my cursor above the line and it does not Find it, giving me the “Done.  Not found in current document.” response.  I uncheck the “Use regular expression” box and it will find it.
    I try using a wildcard (with the box checked), Finding:
    <p class="type_X">([^<]*)< p>
    <p class="type_X">[^”]*< p>
    and it will find the misc. lines, e.g. where the text is “Case #1”, but not the lines of interest, with Heinrich’s name.  With the box unchecked it Finds nothing.
    Really would appreciate help.  Thanks.

    jds zigzag wrote:
    It says to “Use regular expression.”  What does that mean?
    A regular expression is a pattern for matching text. It uses a combination of literal characters and special symbols or sequences of characters (technically called metacharacters or metasequences) to represent such things as the beginning and end of a line or any alphanumeric character. For example, \d represents any number (single digit), \d* represents zero or more numbers in sequence.
    I have written a tutorial series on using regular expressions in Dreamweaver here:
    I try using a wildcard (with the box checked), Finding: 
    <p class="type_X">([^<]*)< p>
    <p class="type_X">[^”]*< p>
    They're not wildcards, but regular expressions. The first part matches the literal characters <p class="type_X">. The next sections use metacharacters.
    ([^<]*) matches zero or more characters (and as many as possible) that don't include an opening angle bracket (<). The parentheses "capture" the value that's matched so it can be used in a replace sequence.
    [^"]* matches zero or more characters (and as many as possible) that don't include a double quote. There are no parentheses, so the value is not captured for reuse.
    The closing <p> matches those literal characters.
    Regular expressions are not easy, but they're extremely powerful, and a good skill to acquire.

Maybe you are looking for

  • How to return multiple values from dialog popup

    hi all I'm using ADF 10g. I have a requirement that I have to return multiple values from a dialog. I have a page containing a table with a button which calls the dialog. The dialog contains a multi-select table where i want to select multiple record

  • Is there a way to split pdfs, i.e., in mid-page?

    I have three pdf files, each of which contains several documents that I expected to be saved as separate pdfs. Working with the documents in this merged form will be extremely awkward to impossible. Unfortunately, the separate documents are run-on ac

  • Display JTree in browser using JSP

    i have a program that converts xml file in to tree structure(using Swing). When i run this using eclipse then it is working. Swing is an extension of applet , right. I want to embed this in an HTML page(JSP). so that i can display the tree structure.


    Hi All My scenario is R/3 --> XI --> thirparty( file) the messages are coming from SAP to XI successfully, but failing to reach third party from XI. and i am unable to see these messages from SXMB_MONI, But i am able see these messages from Runtime w

  • HT204370 Rented movie on an iPad - Where to find it once downloaded?

    I just rented a movie from the Apple Store via my iPad.  Movie said it was downloading.  But I can't find it in my iTunes account nor on my iPad.  Where does the movie get stored and how do I access it?