replaceing a space with a symbol

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

i want to know how to replace a space with a symbol. i am trying to get it so ppl can put spaces in there aim names and it will work. and to do that you have to connect the words with + signs is there away to do this automadicly?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

What language?
Here's some options:
Javascript:
Code: [ Select ]
In The Head:
<script language="JavaScript" type="text/javascript">
function replaceSpaces(string) {
var re = new RegExp (' ', 'gi') ;
var newstr = string.replace(re, '\+') ;
return newstr;
}
</script>

Then in each field you want the replacement done in:
<input name="thefield" value="" size="10" onblur="this.value=replaceSpaces(this.value)">
  1. In The Head:
  2. <script language="JavaScript" type="text/javascript">
  3. function replaceSpaces(string) {
  4. var re = new RegExp (' ', 'gi') ;
  5. var newstr = string.replace(re, '\+') ;
  6. return newstr;
  7. }
  8. </script>
  9. Then in each field you want the replacement done in:
  10. <input name="thefield" value="" size="10" onblur="this.value=replaceSpaces(this.value)">


Perl:
Code: [ Select ]
$input = $ENV{'fieldname'};
$input =~ s/ /\+/g;
  1. $input = $ENV{'fieldname'};
  2. $input =~ s/ /\+/g;


PHP:
Code: [ Select ]
$input = $_GET['fieldname'];
$newstring = str_replace(' ', '+', $input );
  1. $input = $_GET['fieldname'];
  2. $newstring = str_replace(' ', '+', $input );
  • Johan007
  • Guru
  • Guru
  • User avatar
  • Posts: 1080
  • Loc: Aldershot, UK

Post 3+ Months Ago

ASP:
Code: [ Select ]
strNew = replace(strOld," ","+")


Anyone know it in C++
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

woops sorry for not saying what lanuage but it was php and thanks!

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 121 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.