473,805 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with regex expression

Hello all,

I'm not very good with writing regular expressions and need some help
with this one. I need to validate an email address which has the full
name of the person appended to the beginning of it. Here is an example
of what I’m trying to validate.

“firstname lastname” <us******@domai n.com>

I need to enforce this format so the web form won’t allow submit
unless it’s like this. So the regex needs to make sure there is a
word, or two words or more, inside of double quotes, then a space,
then angle backet, then email, then closing angle bracket.

Does anyone have a regex expression that can do this or know how to
write one?
Jun 27 '08 #1
6 1503
mo******@gmail. com wrote:
Hello all,

I'm not very good with writing regular expressions and need some help
with this one. I need to validate an email address which has the full
name of the person appended to the beginning of it. Here is an example
of what I’m trying to validate.

“firstname lastname” <us******@domai n.com>

I need to enforce this format so the web form won’t allow submit
unless it’s like this. So the regex needs to make sure there is a
word, or two words or more, inside of double quotes, then a space,
then angle backet, then email, then closing angle bracket.

Does anyone have a regex expression that can do this or know how to
write one?
I added a bit to a regular expression I had for email verification:

^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #3
Ah, yes. In my haste to write this post I forgot to say that I need
this to validate multiple emails seperated by a semi-colon. I think
this throws a wrench into the problem doesn't it.

On Jun 19, 4:46*am, Göran Andersson <gu...@guffa.co mwrote:
mohaa...@gmail. com wrote:
Hello all,
I'm not very good with writing regular expressions and need some help
with this one. I need to validate an email address which has the full
name of the person appended to the beginning of it. Here is an example
of what I’m trying to validate.
“firstname lastname” <usern...@domai n.com>
I need to enforce this format so the web form won’t allow submit
unless it’s like this. So the regex needs to make sure there is a
word, or two words or more, inside of double quotes, then a space,
then angle backet, then email, then closing angle bracket.
Does anyone have a regex expression that can do this or know how to
write one?

I added a bit to a regular expression I had for email verification:

^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -
Jun 27 '08 #4
on 20-6-2008, mo******@gmail. com supposed :
Ah, yes. In my haste to write this post I forgot to say that I need
this to validate multiple emails seperated by a semi-colon. I think
this throws a wrench into the problem doesn't it.
Not *that* much:

^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"
<[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*$

original test,
followed by zero or more occurences of
optional whitespace, a ';', more optional whitespace and
the original test again.

But maybe the {2,4} multiplier should be adjusted somewhat to at least
{2,6}, as there are now top-level domains of .museum and .travel!

Hans Kesting

On Jun 19, 4:46Â*am, Göran Andersson <gu...@guffa.co mwrote:
>mohaa...@gmail .com wrote:
>>Hello all,
>>I'm not very good with writing regular expressions and need some help
with this one. I need to validate an email address which has the full
name of the person appended to the beginning of it. Here is an example
of what I’m trying to validate.
>>“firstnam e lastname” <usern...@domai n.com>
I need to enforce this format so the web form won’t allow submit
unless it’s like this. So the regex needs to make sure there is a
word, or two words or more, inside of double quotes, then a space,
then angle backet, then email, then closing angle bracket.
Does anyone have a regex expression that can do this or know how to
write one?

I added a bit to a regular expression I had for email verification:

^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Jun 27 '08 #5
Hello Hans,

Thank you so much for getting me this. I'm having a problem with it
though. When I enter the semi-colon at the end to all a second name +
email to be entered it doesn't validate anymore.

The following doesn't work.

"firstname lastname" <us******@domai n.com>;

I need this to work as well as this.

"firstname lastname" <us******@domai n.com>; "firstname lastname"
<us******@domai n.com>;

Is this hard to change?

On Jun 20, 2:57*am, Hans Kesting <news.han...@sp amgourmet.comwr ote:
on 20-6-2008, mohaa...@gmail. com supposed :
Ah, yes. In my haste to write this post I forgot to say that I need
this to validate multiple emails seperated by a semi-colon. I think
this throws a wrench into the problem doesn't it.

Not *that* much:

^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"
<[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*$

original test,
followed by zero or more occurences of
* *optional whitespace, a ';', more optional whitespace and
* *the original test again.

But maybe the {2,4} multiplier should be adjusted somewhat to at least
{2,6}, as there are now top-level domains of .museum and .travel!

Hans Kesting
On Jun 19, 4:46*am, Göran Andersson <gu...@guffa.co mwrote:
mohaa...@gmail. com wrote:
Hello all,
>I'm not very good with writing regular expressions and need some help
with this one. I need to validate an email address which has the full
name of the person appended to the beginning of it. Here is an example
of what I’m trying to validate.
>“firstname lastname” <usern...@domai n.com>
I need to enforce this format so the web form won’t allow submit
unless it’s like this. So the regex needs to make sure there is a
word, or two words or more, inside of double quotes, then a space,
then angle backet, then email, then closing angle bracket.
Does anyone have a regex expression that can do this or know how to
write one?
I added a bit to a regular expression I had for email verification:
^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$
--
Göran Andersson
_____http://www.guffa.com-Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Jun 27 '08 #6
mo******@gmail. com pretended :
Hello Hans,

Thank you so much for getting me this. I'm having a problem with it
though. When I enter the semi-colon at the end to all a second name +
email to be entered it doesn't validate anymore.

The following doesn't work.

"firstname lastname" <us******@domai n.com>;

I need this to work as well as this.

"firstname lastname" <us******@domai n.com>; "firstname lastname"
<us******@domai n.com>;

Is this hard to change?
Just add an extra optional ';'

^"[^"]+"
<[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"<[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*;?$
Hans Kesting
On Jun 20, 2:57Â*am, Hans Kesting <news.han...@sp amgourmet.comwr ote:
>on 20-6-2008, mohaa...@gmail. com supposed :
>>Ah, yes. In my haste to write this post I forgot to say that I need
this to validate multiple emails seperated by a semi-colon. I think
this throws a wrench into the problem doesn't it.

Not *that* much:

^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>(\s*;\s*"[^"]+"
<[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>)*$

original test,
followed by zero or more occurences of
Â* Â*optional whitespace, a ';', more optional whitespace and
Â* Â*the original test again.

But maybe the {2,4} multiplier should be adjusted somewhat to at least
{2,6}, as there are now top-level domains of .museum and .travel!

Hans Kesting
>>On Jun 19, 4:46Â*am, Göran Andersson <gu...@guffa.co mwrote:
mohaa...@gma il.com wrote:
Hello all,
>>>>I'm not very good with writing regular expressions and need some help
with this one. I need to validate an email address which has the full
name of the person appended to the beginning of it. Here is an example
of what I’m trying to validate.
>>>>“firstnam e lastname” <usern...@domai n.com>
I need to enforce this format so the web form won’t allow submit
unless it’s like this. So the regex needs to make sure there is a
word, or two words or more, inside of double quotes, then a space,
then angle backet, then email, then closing angle bracket.
Does anyone have a regex expression that can do this or know how to
write one?
>>>I added a bit to a regular expression I had for email verification:
^"[^"]+" <[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}>$
--
Göran Andersson
_____http://www.guffa.com-Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Jun 27 '08 #7

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

Similar topics

6
1944
by: Maurice LING | last post by:
Hi, I have the following codes: from __future__ import nested_scopes import re from UserDict import UserDict class Replacer(UserDict):
1
2060
by: tdmailbox | last post by:
I have the following regular expression. It works fine if the regex code returns a match. However if not the .match code fails. How can I code this so that it skips the match if the regular expression does not find anything? Regex reg_unit_num = new Regex("L_unit_num.*?>(.*?)</td>", RegexOptions.IgnoreCase);
3
2308
by: Joe | last post by:
Hi, I have been using a regular expression that I don’t uite understand to filter the valid email address. My regular expression is as follows: <asp:RegularExpressionValidator id="valValidEmail" runat="server" ControlToValidate="txtEmail" ValidationExpression="^(+)(\.+)*@(+)(\.+)*(\.{2,4})$"
18
3047
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
2
1496
by: JebBushell | last post by:
I see signs that the ASP.NET regular expression validator has a different instruction set that the Find utility in VS 2003. I am trying to use the VS2003 regular expression Find tool to test regular expressions for use in a ASP.NET validator. The results I am getting are inconsistent . What works in VS does not always work in ASP.NET and vice versa. For example: +({0,1})(*)
1
1105
by: hillcountry74 | last post by:
Hi, I'm stuck with this regular expression from past 2 days. Desperately need help. I need a regular expression that will allow all characters except these *:~<>' This is my code in VB.Net-
5
5109
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated by a tool. ' Runtime Version: 1.1.4322.2032 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </autogenerated>
17
2795
by: Mark | last post by:
I must create a routine that finds tokens in small, arbitrary VB code snippets. For example, it might have to find all occurrences of {Formula} I was thinking that using regular expressions might be a neat way to solve this, but I am new to them. Can anyone give me a hint here? The catch is, it must only find tokens that are not quoted and not commented; examples follow
6
2240
by: deepak_kamath_n | last post by:
Hello, I am relatively new to the world of regex and require some help in forming a regular expression to achieve the following: I have an input stream similar to: Slot: slot1 Description: this is a description Slot: slot2
0
10609
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10360
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9185
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5542
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.