Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    56
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Manipulating a string contained in a HTML table data

    Hi ,

    I have javascript variable (var path) which is conatining the table data of particular table row and column. Following line is the code :

    Code:
    var path = mytable.rows[i].cells[3].innerHTML;
    The 'path' variable is containing :

    <a href="coll.pl?path=/home/common/units">(/home/common/units)</a>

    My requirement is to extract the path information (i.e /home/common/units )
    from the above string. How can I do that ?

    Please help.

    Thanks.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Try the following code which uses a regular expression
    Code:
    var myRegex = /path=(.*)"/;
    path = path.match(myRegex)[1];
    Last edited by devnull69; 10-09-2012 at 03:57 PM.

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    56
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks a lot devnull69. It is working.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •