string replacer in javascript

Discussion in 'Web Design and Development' started by ombrenelcielo, Sep 22, 2011.

  1. ombrenelcielo macrumors regular

    ombrenelcielo

    Joined:
    Jan 21, 2011
    Location:
    Helsinki, Finland
    #1
    Hi all,
    I am doing some research in my spare time to write a small script that checks and modifies logs written in XML..

    Logs have this format:
    PHP:
    <value="sometexthere">
          <
    text>this is a place mark %%==here==%%</text>
    </
    value>
    What I am trying to achieve is to have a solution to replace a fixed place mark %%==here==%% with what stored in the element value.

    I know that's very simple in perl and it's not a problem for me to script it in that language, but I wanted to ask you what could be a smart way to do it in javascript.

    I guess I could use something like .replace(/%%==here==%%/, to capture the place holder, but then I would need to grab the value as element to put it in the replace function.
    And being XML and not html I of course can't use getelementby... to grab my value=""

    Any help appreciated :)
     
  2. ergdegdeg Moderator emeritus

    ergdegdeg

    Joined:
    Oct 13, 2007
    #2
  3. ombrenelcielo thread starter macrumors regular

    ombrenelcielo

    Joined:
    Jan 21, 2011
    Location:
    Helsinki, Finland
  4. ombrenelcielo thread starter macrumors regular

    ombrenelcielo

    Joined:
    Jan 21, 2011
    Location:
    Helsinki, Finland
    #4
    In the end I've opted to write a script in perl to parse the files, much easier.
    I'll get my hands on this whenever I will have time :)
     

Share This Page