in java I want to check A String as mail
I have done but i think itisn't true
17 1747
in java I want to check A String as mail
I have done but i think itisn't true
Post your Code what you tried so far with Code Tags.
One more thing do you know regular expression.
Have a look at this and try it using Regular Expression.
Mind it, Reg Exp. supported in J2SE-1.5 :-)
Kind regards,
Dmjpro.
Post your Code what you tried so far with Code Tags.
One more thing do you know regular expression.
Have a look at this and try it using Regular Expression.
Mind it, Reg Exp. supported in J2SE-1.5 :-)
Kind regards,
Dmjpro.
class StringDemo{
public static boolean isEmailAddress(String address) {
int dot,at;
dot = address.indexOf(".");
at = address.indexOf("@");
if( at ==-1 ||dot==-1|| address.length()< dot||(dot<at)&&) return false;
else return true;
}
public static void main( String[] arg){
System.out.println(isEmailAddress("lenguye..@"));
}
}
but if string conatin dot before @ i can't process
help me !! this probelem i think it isn't difficult to you
thanks
class StringDemo{
public static boolean isEmailAddress(String address) {
int dot1,at1,dot2,at2;
dot = address.indexOf(".");
at = address.indexOf("@");
if( at ==-1 ||dot==-1|| address.length()< dot||(dot<at)&&) return false;
else return true;
}
public static void main( String[] arg){
System.out.println(isEmailAddress("lenguye..@"));
}
}
but if string conatin dot before @ i can't process
Please use Code Tags.
So you are checking that only one occurrence of "." and "@".
Right :-)
It will be possible with Regular Expression but I am not familiar with Regular Expression, so I am doing it using plain Java Code. -
public static boolean isEmailAddress(String address) {
-
int dot,at;
-
dot1 = address.indexOf(".");
-
at1 = address.indexOf("@");
-
dot2 = address.lastIndexOf(".");
-
at2 = address.lastIndexOf("@");
-
if(dot1!=-1 && at1 !=-1 && dot1 != dot2 && at1 != at2) return true;
-
else return false;
-
}
-
Enjoy the code :-)
Good Luck !
Kind regards,
Dmjpro.
Always use a regular expression for this stuff, something like - Pattern.compile(".+@.+\\.[a-z]+");
Please use Code Tags.
So you are checking that only one occurrence of "." and "@".
Right :-)
It will be possible with Regular Expression but I am not familiar with Regular Expression, so I am doing it using plain Java Code. -
public static boolean isEmailAddress(String address) {
-
int dot,at;
-
dot1 = address.indexOf(".");
-
at1 = address.indexOf("@");
-
dot2 = address.lastIndexOf(".");
-
at2 = address.lastIndexOf("@");
-
if(dot1!=-1 && at1 !=-1 && dot1 != dot2 && at1 != at2) return true;
-
else return false;
-
}
-
Enjoy the code :-)
Good Luck !
Kind regards,
Dmjpro.
that code above it can't run true
it's true when i input 2 dot and 2 @
that code above it can't run true
it's true when i input 2 dot and 2 @
Sorry I did a great mistake, :-(
Can't you change it yourself buddy, please apply your own brain when you have it :-)
Anyway ! -
if(dot1!=-1 && at1 !=-1 && dot1 == dot2 && at1 == at2) return true
-
else return false;
-
Kind regards,
Dmjpro.
that code above it can't run true
it's true when i input 2 dot and 2 @
you can check this code
public boolean isEmailAddress(String address) {
int At,Dot,DO;
At = address.indexOf("@",0);
Dot = address.indexOf(".",At+1);
if(address.length() > Dot) DO = 1;
else = -1;
if((At == -1) || (Dot == -1) || (Do == -1)) return false;
return true;
}
you can check this code
public boolean isEmailAddress(String address) {
int At,Dot,DO;
At = address.indexOf("@",0);
Dot = address.indexOf(".",At+1);
if(address.length() > Dot) DO = 1;
else = -1;
if((At == -1) || (Dot == -1) || (Do == -1)) return false;
return true;
}
What about my code?
Kind regards,
Dmjpro.
Throw all that stuff away and use regular expressions. They are the right tool for the job.
P.S If you guys really like to learn Java, you have to first learn to take advice.
Throw all that stuff away and use regular expressions. They are the right tool for the job.
P.S If you guys really like to learn Java, you have to first learn to take advice.
Yeah it's right, but I think if it is done then he or she can learn the logic development.
But finally he or she will do that using Reg Exp.
Don't mind Admin, if I told anything wrong.
Kind regards,
Dmjpro.
Always use a regular expression for this stuff, something like - Pattern.compile(".+@.+\\.[a-z]+");
That thing accepts two or more dots next to each other and multiple at-signs
all over the place. I'm afraid the RE is more complicated than that:
1) [^\.@]+
accepts anything without dots and at-signs, so
2) [^\.@]+(\.[\.@]+)*
accepts sequences of 1) separated by a single dot. This little beast accepts
all stuff to the left of the at-sign in a (potential) email address.
The part to the right of the at-sign is similar to 2) but there's a top level domain
name as the rightmost part:
3) [^\.@]+(\.[\.@]+)*\\.[a-z]+
Now 2) and 3) together, separated by an at-sign accepts an email address:
[^\.@]+(\.[\.@]+)*@[^\.@]+(\.[\.@]+)*\\.[a-z]+
*yuck* ;-)
kind regards,
Jos
That thing accepts two or more dots next to each other and multiple at-signs
all over the place. I'm afraid the RE is more complicated than that:
1) [^\.@]+
accepts anything without dots and at-signs, so
2) [^\.@]+(\.[\.@]+)*
accepts sequences of 1) separated by a single dot. This little beast accepts
all stuff to the left of the at-sign in a (potential) email address.
The part to the right of the at-sign is similar to 2) but there's a top level domain
name as the rightmost part:
3) [^\.@]+(\.[\.@]+)*\\.[a-z]+
Now 2) and 3) together, separated by an at-sign accepts an email address:
[^\.@]+(\.[\.@]+)*@[^\.@]+(\.[\.@]+)*\\.[a-z]+
*yuck* ;-)
kind regards,
Jos
I just plugged that from devx and never bothered to check it.
There's another way of doing it in parts doesn't look cleaner as well (but regexs are not always clean anyway).
So you did a match by eliminating the illegal characters, the OP doesn't want to use them anyway ...
I just plugged that from devx and never bothered to check it.
There's another way of doing it in parts doesn't look cleaner as well (but regexs are not always clean anyway).
So you did a match by eliminating the illegal characters, the OP doesn't want to use them anyway ...
Ah, yes, if you assume that the email address is correct anyway, your RE:
".+@.+\\.[a-z]+" works fine of course. There's an old saying in the compiler
'world' that goes: "any fool can write a compiler for a perfect user" (no insult
intended).
kind regards,
Jos@.....@@.@.@.@....foo
i understand that but I can't process email like sadgasdaga@gsadg.
i use address.length() but no - help me again
That thing accepts two or more dots next to each other and multiple at-signs
all over the place. I'm afraid the RE is more complicated than that:
1) [^\.@]+
accepts anything without dots and at-signs, so
2) [^\.@]+(\.[\.@]+)*
accepts sequences of 1) separated by a single dot. This little beast accepts
all stuff to the left of the at-sign in a (potential) email address.
The part to the right of the at-sign is similar to 2) but there's a top level domain
name as the rightmost part:
3) [^\.@]+(\.[\.@]+)*\\.[a-z]+
Now 2) and 3) together, separated by an at-sign accepts an email address:
[^\.@]+(\.[\.@]+)*@[^\.@]+(\.[\.@]+)*\\.[a-z]+
*yuck* ;-)
kind regards,
Jos
i'm sorry evrybody - because i have never used regular expression and the first i do about mail
i understand that but I can't process email like sadgasdaga@gsadg.
i use address.length() but no - help me again
Are you using regex for this yet?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mcp6453 |
last post by:
I am trying to use Jack's FormMail script
(http://www.dtheatre.com/scripts/formmail). Since I'm brand new at PHP
and not very good at HTML, I have an easy question, which I will narrow
down. When...
|
by: Sue |
last post by:
<html>
Is there someone here that can help me validate the period as the
fourth from the last character in an email address. There is other
information and validation on the form I have to do but...
|
by: YZK |
last post by:
Hello. I'm not a Web developer, just a user, and I think I may have
somehow messed myself up majorly. I'm not quite sure how. Right now,
javascript used by websites I go to either does not work at...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: tyler_durden |
last post by:
thanks a lot for all your help..I'm really appreciated...
with all the help I've been getting in forums I've been able to continue
my program and it's almost done, but I'm having a big problem that...
|
by: Mike Brearley |
last post by:
I need to write a script that will check a catch-all mailbox (pop3) and send
a non delivery report back to the sender of the email.
Background info:
I have a domain hosted on a site that offers...
|
by: James Radke |
last post by:
Hello,
I have a multithreaded windows NT service application (vb.net 2003) that I
am working on (my first one), which reads a message queue and creates
multiple threads to perform the processing...
|
by: cybervigilante |
last post by:
I can't seem to change the include path on my local winmachine no
matter what I do. It comes up as
includ_path .;C:\php5\pear in phpinfo() but there is no such file. I
installed the WAMP package...
|
by: CodeSeeker |
last post by:
I have an application, which uses pop3 to read the messages from the mailbox, and it has been working fine for so many year. We recently have started changing this application to use java mail IMAP 4...
|
by: zhang |
last post by:
what's the problem??
Remote_Addr = "hotmail.com"
sFrom = "<makefriend8@" & Remote_Addr + ">"
Dim oConnection As New TcpClient()
Try
oConnection.SendTimeout = 3000
...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |