Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Remove characters from string

Reply
Thread Tools

Remove characters from string

 
 
Jon
Guest
Posts: n/a
 
      04-27-2005
Hello all,

Would anyone please be able to help?

I would like to remove all characters after and including the @ from a
string, for example the string http://www.velocityreviews.com/forums/(E-Mail Removed) would become
Joe Bloggs.

Thanks You all,

Jon
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-27-2005


Jon wrote:


> I would like to remove all characters after and including the @ from a
> string, for example the string (E-Mail Removed) would become
> Joe Bloggs.


"(E-Mail Removed)".replace(/@.*/, '')

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Dietmar Meier
Guest
Posts: n/a
 
      04-27-2005
Jon wrote:

> I would like to remove all characters after and including the @ from a
> string,


myString = myString.replace(/@.*/, "");

Or, compatible with very old script engines

var atpos = myString.indexOf("@");
if (atpos > -1) {
myString = myString.substring(0, atpos);
}

> for example the string (E-Mail Removed) would become
> Joe Bloggs.


Did you mean "joe.Bloggs"?

ciao, dhgm
 
Reply With Quote
 
Mick White
Guest
Posts: n/a
 
      04-27-2005
Jon wrote:

> Hello all,
>
> Would anyone please be able to help?
>
> I would like to remove all characters after and including the @ from a
> string, for example the string (E-Mail Removed) would become
> Joe Bloggs.
>


<script type="text/JavaScript">
var jb="(E-Mail Removed)".split("@")[0].replace(/\./," ")
jb=jb.charAt(0).toUpperCase()+jb.substring(1);
alert(jb);
</script>

Mick
 
Reply With Quote
 
RobB
Guest
Posts: n/a
 
      04-27-2005
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body>
<script type="text/javascript">

function user(addr)
{
return addr
.replace(/^(.+)@.*$/, '$1')
.replace(/\./g, ' ')
.replace(/\b./g, function(a){return a.toUpperCase();})
}

document.write(

'<pre>' ,
user('(E-Mail Removed)') ,
'\n' ,
user('(E-Mail Removed)') ,
'\n' ,
user('foo.Bar@haha/vavoom.net') ,
'</pre>'

);

</script>
</body>
</html>

 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      04-27-2005
JRS: In article <(E-Mail Removed) >,
dated Wed, 27 Apr 2005 08:44:16, seen in news:comp.lang.javascript, Jon
<(E-Mail Removed)> posted :

>I would like to remove all characters after and including the @ from a
>string, for example the string (E-Mail Removed) would become
>Joe Bloggs.


S = "(E-Mail Removed)"
S = S.split('@')[0]

is another way.

S = "(E-Mail Removed)"
T = S.split('@') // T[0] & T[1] may be useful

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove only special characters and junk characters from a file rvino Perl 0 08-14-2007 07:23 AM
How to remove and substitute characters within a string francescomoi@europe.com C Programming 4 04-30-2005 01:44 AM
Interrogating string for number of characters, response.writing identical number of characters on new line Ken Fine ASP General 2 02-05-2004 03:40 AM
Remove no-printable characters in string Pascal Python 3 12-04-2003 05:07 PM
Remove no-printable characters in string Pascal Python 0 12-03-2003 11:17 AM



Advertisments