473,385 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

TrimEnd doesn't work with email address

I'm trying t use these lines below to get "new string = "someone", but
it won't work. Instead it just keeps coming back as
"so*****@domain.com". Is there something weird about there being an "@"
character or a "." character?

'Dim MyString As String = "so*****@domain.com"
'Dim MyChar As Char() = {"."c, "@"c}
'Dim NewString As String = MyString.TrimEnd(MyChar)
'lblHolder.Text = NewString

Thanks,
Ezra

Nov 23 '05 #1
3 1427
I think you have misunderstood how the TrimEnd methods works
You're telling it to remove all "." and "@" from the *end* of the string.
Since your string doesn't have any of those in the end, you'll simply
get the input string back. If you were to pass so*****@domain.com@@@....
you would get so*****@domain.com back

Use this instead:
Dim NewString As String = MyString.Split("@"c)(0)

/claes
<ez****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I'm trying t use these lines below to get "new string = "someone", but
it won't work. Instead it just keeps coming back as
"so*****@domain.com". Is there something weird about there being an "@"
character or a "." character?

'Dim MyString As String = "so*****@domain.com"
'Dim MyChar As Char() = {"."c, "@"c}
'Dim NewString As String = MyString.TrimEnd(MyChar)
'lblHolder.Text = NewString

Thanks,
Ezra

Nov 23 '05 #2
Thanks. That did it.
Ezra

Nov 23 '05 #3
Ezra,
In addition to using Split. I would consider using String.SubString along
with String.IndexOf or String.LastIndexOf, something like:

Dim MyString As String = "so*****@domain.com"
Dim MyChar As Char() = {"."c, "@"c}
Dim NewString As String
If MyString.IndexOfAny(MyChar) <> -1 Then
NewString = MyString.Substring(0,
MyString.LastIndexOfAny(MyChar))
End If

I would use IndexOfAny if I wanted to split at the first occurrence and
LastIndexOfAny if I wanted to split at the last occurrence.

FWIW: Consider what happens in the above with addresses such as
so******@domain.com, I know of a couple of Lotus Notes sites that use
fi****************@domain.com for their email addresses...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<ez****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
| I'm trying t use these lines below to get "new string = "someone", but
| it won't work. Instead it just keeps coming back as
| "so*****@domain.com". Is there something weird about there being an "@"
| character or a "." character?
|
| 'Dim MyString As String = "so*****@domain.com"
| 'Dim MyChar As Char() = {"."c, "@"c}
| 'Dim NewString As String = MyString.TrimEnd(MyChar)
| 'lblHolder.Text = NewString
|
| Thanks,
| Ezra
|
Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: OldGuy | last post by:
Hi All Sendmail 8.12.11 php 4.3.9 Sendmail is installed and works properly. php is NOT in safemode from the command line; mail user@domain.com < testmsg works fine.
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
4
by: Joe | last post by:
Hello, I have created a login page using dotnet. I am using requiredFieldValidator and noticed that the code works fine in IE but not in Netscape, Opera, Mozilla, Firefox, etc. For example...
1
by: tshad | last post by:
I have a string that I am trying to strip the last 2 characters that happen to be a "," and a " ". I am also adding a "<br>" to the end. When I am done I still have the ", " and also the <br>. ...
21
by: briggs | last post by:
<html> <head> <script> /* AddChild */ function ac() { var c; var p = document.getElementById("p"); for (var i = 0; i < 5; i++) { c = document.createElement("DIV"); // Create 'div' element.
3
by: =?Utf-8?B?Sm9obk1TeXJhc29mdA==?= | last post by:
Hi, Why am I getting unexpected results here? This is VB.NET 2005 from my Immediate Window. See 2nd line. ?"test.trim".TrimEnd("trim".ToCharArray) "test."...
3
by: whitey | last post by:
this code is producing the message BUT it is entering the data. What should i do? <?php if (!$_POST) { //haven't seen the form, so show it $display_block = " <form...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.