473,566 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help for regular expression

Hi,

I can't figure out what the regular expression would look like for
validating a string such as :

Lastname, Firstname

I could only come up with /\w/ which doesn't check for the comma.

Can someone help ?

Thanks
Jan 24 '08 #1
7 1854
gr********@goog lemail.com wrote:
I can't figure out what the regular expression would look like for
validating a string such as :

Lastname, Firstname
/\w+, \w+/

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 24 '08 #2
On 24 Jan, 17:31, Martin Honnen <mahotr...@yaho o.dewrote:
graphic...@goog lemail.com wrote:
I can't figure out what the regular expression would look like for
validating a string such as :
Lastname, Firstname

* */\w+, \w+/

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
Thanks for the help ! Actually it's not exactly what I need as this
would only check for the coma and other characters around the coma.
The expression needs to check for litterals only and one comma only.

Thanks
Jan 24 '08 #3
Lee
gr********@goog lemail.com said:
>
On 24 Jan, 17:31, Martin Honnen <mahotr...@yaho o.dewrote:
>graphic...@goo glemail.com wrote:
I can't figure out what the regular expression would look like for
validating a string such as :
Lastname, Firstname

=A0 =A0/\w+, \w+/

--

=A0 =A0 =A0 =A0 Martin Honnen
=A0 =A0 =A0 =A0http://JavaScript.FAQT s.com/

Thanks for the help ! Actually it's not exactly what I need as this
would only check for the coma and other characters around the coma.
The expression needs to check for litterals only and one comma only.
Martin's regular expression checks for more than zero alphabetic or
numeric characters, followed by a single comma then a single space,
followed by more than zero alphabetic or numeric characters.

What do you believe "literal" means? If you want alphabetic
characters only , the expression would be:

/[a-z]+,\s*[a-z]+/i

This also allows zero or more spaces or tabs (or other whitespace)
after the comma.
--

Jan 24 '08 #4
gr********@goog lemail.com wrote:
On 24 Jan, 17:31, Martin Honnen <mahotr...@yaho o.dewrote:
>graphic...@goo glemail.com wrote:
>>I can't figure out what the regular expression would look like for
validating a string such as : Lastname, Firstname
/\w+, \w+/

[signature]

[...] Actually it's not exactly what I need
Tough luck. Use Brain 1.0:

http://jibbering.com/faq/
http://developer.mozilla.org/en/docs...Objects:RegExp
as this would only check for the coma and other characters around the
coma. The expression needs to check for litterals only and one comma
only.
Once you get out of your coma, you may be able to post an understandable
message.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jan 24 '08 #5
On Jan 24, 1:20*pm, Lee <REM0VElbspamt. ..@cox.netwrote :
graphic...@goog lemail.com said:


On 24 Jan, 17:31, Martin Honnen <mahotr...@yaho o.dewrote:
graphic...@goog lemail.com wrote:
I can't figure out what the regular expression would look like for
validating a string such as :
Lastname, Firstname
=A0 =A0/\w+, \w+/
--
=A0 =A0 =A0 =A0 Martin Honnen
=A0 =A0 =A0 =A0http://JavaScript.FAQT s.com/
Thanks for the help ! Actually it's not exactly what I need as this
would only check for the coma and other characters around the coma.
The expression needs to check for litterals only and one comma only.

Martin's regular expression checks for more than zero alphabetic or
numeric characters, followed by a single comma then a single space,
followed by more than zero alphabetic or numeric characters.

What do you believe "literal" means? *If you want alphabetic
characters only , the expression would be:

/[a-z]+,\s*[a-z]+/i

This also allows zero or more spaces or tabs (or other whitespace)
after the comma.
better make that: /^[a-z]+,\s*[a-z]+$/i
Jan 24 '08 #6
Lee
nolo contendere said:
>
On Jan 24, 1:20=A0pm, Lee <REM0VElbspamt. ..@cox.netwrote :
>graphic...@goo glemail.com said:


>On 24 Jan, 17:31, Martin Honnen <mahotr...@yaho o.dewrote:
graphic...@goo glemail.com wrote:
I can't figure out what the regular expression would look like for
validating a string such as :
Lastname, Firstname
>=3DA0 =3DA0/\w+, \w+/
>--
>=3DA0 =3DA0 =3DA0 =3DA0 Martin Honnen
=3DA0 =3DA0 =3DA0 =3DA0http://JavaScript.FAQT s.com/
>Thanks for the help ! Actually it's not exactly what I need as this
would only check for the coma and other characters around the coma.
The expression needs to check for litterals only and one comma only.

Martin's regular expression checks for more than zero alphabetic or
numeric characters, followed by a single comma then a single space,
followed by more than zero alphabetic or numeric characters.

What do you believe "literal" means? =A0If you want alphabetic
characters only , the expression would be:

/[a-z]+,\s*[a-z]+/i

This also allows zero or more spaces or tabs (or other whitespace)
after the comma.

better make that: /^[a-z]+,\s*[a-z]+$/i
Yes. I was sure I had anchored it, but apparently not.
--

Jan 24 '08 #7
In comp.lang.javas cript message <c5dc03c1-54c7-410d-8d07-aa88b8d6dac6@n2
0g2000hsh.googl egroups.com>, Thu, 24 Jan 2008 09:16:16,
gr********@goog lemail.com posted:
>
I can't figure out what the regular expression would look like for
validating a string such as :

Lastname, Firstname
A correct solution will allow for people whose family (or other) name
contains non-alphabetic characters.

Consider :
Jean-Jacques Rousseau
Patrick O'Brian
Sir Ian Moncrieffe of that Ilk
François Mitterand
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Jan 24 '08 #8

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

Similar topics

9
3684
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various pages. I have been programming in PHP for over 2 years now and have never encountered a problem like the one I am having now. To me this seems...
5
2500
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL, and then reconstruct another URL based on it. For example, I need to scan a web page looking for something like <a...
4
3213
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go over each document, find out if it contains a header and/or a footer and extract only the main content part. The headers and the footers have no...
6
489
by: JohnSouth | last post by:
Hi I've been using a Regular expression to test for valid email addresses. It looks like: \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* I've now had 2 occassions where it has rejected and email address with a "&" character in the local part. I know I should be able to work it out myself, but I'd like to ask anyone to suggest the best way to
3
2280
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})$"
1
3698
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am...
3
2554
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular expression. ^(.+?) uses (?!a spoon)\.$
6
2222
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
14
2251
by: Chris | last post by:
I need a pattern that matches a string that has the same number of '(' as ')': findall( compile('...'), '42^((2x+2)sin(x)) + (log(2)/log(5))' ) = Can anybody help me out? Thanks for any help!
3
1822
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular expression that only returns part of a string. For Example I have a multi-line text fragment like below:
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8108
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...
1
7644
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...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
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...

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.