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
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts

    Is it posable to Convert the Char "a" to say "b"

    hello
    Code:
    var String = "hat and a  bat"
    Can i canovert the a's to a b's uing javascript

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Yes, on using Regular Expressions
    http://lawrence.ecorp.net/inet/samples/regexp-intro.php
    Code:
    <script type="text/javascript">
    var string = "hat and a  bat";
    string=string.replace(/a/g,'b');
    alert(string)
    </script>
    Note: String is a reserved javascript word. Don't use it as a name, id, custom function, method, variable or argument.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Thanks and i know that it was just an exsample lol


  •  

    Posting Permissions

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