javascript regexp help

Last post 11-09-2006 6:30 PM by SuperGhost. 3 replies.

Sort Posts:

  • javascript regexp help

    11-08-2006, 1:54 PM
    • Member
      685 point Member
    • jibber
    • Member since 10-12-2006, 11:42 AM
    • Posts 209

    I'm very nearly there with a TinyMCE plugin but am struggling with regex.  Can somebody point me in the direction of a good tutorial/reference my Google searches have pulled back little in the way of a good reference.

    In particular I'm trying to replace a string <img src="mysource"/> to <img src="~/mysource"/>  I then need somehow to replace that again when my aspx page chucks out the html so need to replace ~ with "../../" whatever

     

  • Re: javascript regexp help

    11-08-2006, 8:42 PM
    • Contributor
      4,615 point Contributor
    • imran.nathani
    • Member since 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    this shud gv u a fair idea

    <html>
    <body>
    <script type="text/javascript">
    var i=0;
    var a ="<img src=\"datasource\"'>";
    var b ="";
    while (a.charAt(i)!="=")
    {
    b=b+a.charAt(i);
    i=i+1;
    }
    b=b+a.charAt(i);
    i=i+1;
    b=b+a.charAt(i);
    b=b+"~\\";
    i=i+1;
    while(i<a.length)
    {
    b=b+a.charAt(i);
    i=i+1;
    }
    alert(b);
    </script>
    </body>
    </html>

  • Re: javascript regexp help

    11-09-2006, 5:56 AM
    • Member
      685 point Member
    • jibber
    • Member since 10-12-2006, 11:42 AM
    • Posts 209

    Imran thanks and interesting that you didn't regex it, I shall give it a whirl

    cheers

    Jib

  • Re: javascript regexp help

    11-09-2006, 6:30 PM
    • Participant
      1,738 point Participant
    • SuperGhost
    • Member since 12-29-2005, 11:58 AM
    • Palmdale CA, USA
    • Posts 409

    A good reference website is www.regexlib.com

     

    ** Hope this helps!

    DennyDotNet
    Social42.com
Page 1 of 1 (4 items)