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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    need help for regular expression

    Hi all,

    I am new to the regular expression. i need to get string in between two '$' signs, like data from $data$. May i get the matched string as an array in case
    of more than one match? please help, Thanks in advance

    Regards,
    Raneesh

  • #2
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    PHP Code:
    <script type="text/javascript">

    var 
    test "This will $pull$ out the $keywords$ raped in $US Currency$ signs signs"
    var mySplitResult test.split("$");

    document.write(mySplitResult[1]+'<br />');
    document.write(mySplitResult[3]+'<br />');
    document.write(mySplitResult[5]+'<br />');
    </script> 
    if you can follow the patten this will seperate the words inbetween $ so mySplitResult[0] = "This will" ect...

    Hope this helps

  • Users who have thanked barkermn01 for this post:

    raneeshak (08-28-2008)

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks barkermn01 for the help. but it seems to have some problems when there is \$. Almost it worked for me


    Quote Originally Posted by barkermn01 View Post
    PHP Code:
    <script type="text/javascript">

    var 
    test "This will $pull$ out the $keywords$ raped in $US Currency$ signs signs"
    var mySplitResult test.split("$");

    document.write(mySplitResult[1]+'<br />');
    document.write(mySplitResult[3]+'<br />');
    document.write(mySplitResult[5]+'<br />');
    </script> 
    if you can follow the patten this will seperate the words inbetween $ so mySplitResult[0] = "This will" ect...

    Hope this helps

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    that is because your escaping the $ to fix it when u get \$ use \\$ that way the \ is escaped befor it escapes the $ it sould then work for you


  •  

    Posting Permissions

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