HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- regular expressions please help me
Operating System - HP-UX
1829574
Members
4422
Online
109992
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 07:39 AM
11-15-2004 07:39 AM
hi,
Can somebody help me with checking the format of the mail adress.
"@" character should be included in the mail adress.
For example:
User should type an valid mail adress.
name@domainname.com
thank you in advance
idriz
Can somebody help me with checking the format of the mail adress.
"@" character should be included in the mail adress.
For example:
User should type an valid mail adress.
name@domainname.com
thank you in advance
idriz
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 07:46 AM
11-15-2004 07:46 AM
Re: regular expressions please help me
grep address
You something like this.
cat "address" | tr -d "@"
stat=$(echo $?)
if [ ${stat} -ne 0 ];then
echo "not a valid address"
exit 1
else
echo "Valiad from address"
exit 0
fi
Anil
You something like this.
cat "address" | tr -d "@"
stat=$(echo $?)
if [ ${stat} -ne 0 ];then
echo "not a valid address"
exit 1
else
echo "Valiad from address"
exit 0
fi
Anil
There is no substitute to HARDWORK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 07:58 AM
11-15-2004 07:58 AM
Solution
with perl :
#echo test | perl -e 'while () { chomp; ~ m/^.*@.*$/g; print "Not a valid address!\n" if (!pos); }'
Not a valid address!
#echo test@domain.com | perl -e 'while () { chomp; ~ m/^.*@.*$/g; print "Not a valid address!\n" if (!pos); }'
#
Regards,
Fred
#echo test | perl -e 'while (
Not a valid address!
#echo test@domain.com | perl -e 'while (
#
Regards,
Fred
--
"Reality is just a point of view." (P. K. D.)
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 08:02 AM
11-15-2004 08:02 AM
Re: regular expressions please help me
Something like this should work:
ADDRESS="cstephen@xyz.com"
echo "${ADDRESS}" | grep -E -q '^[a-zA-Z]+@[a-zA-Z0-9]$'
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "Pattern ok"
else
echo "Pattern bad"
fi
The -q put grep -E in quiet mode. We are only interested in the status. Change ${ADDRESSS} to a value without the @ and it should fail with ${STAT} being set to a non-zero value.
A more rigorous test would probably use awk to split the address into an array using the @ and then do an nslookup for an MX record.
ADDRESS="cstephen@xyz.com"
echo "${ADDRESS}" | grep -E -q '^[a-zA-Z]+@[a-zA-Z0-9]$'
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "Pattern ok"
else
echo "Pattern bad"
fi
The -q put grep -E in quiet mode. We are only interested in the status. Change ${ADDRESSS} to a value without the @ and it should fail with ${STAT} being set to a non-zero value.
A more rigorous test would probably use awk to split the address into an array using the @ and then do an nslookup for an MX record.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP