Board index » javascript » help for regular expression

help for regular expression

2008-01-25 01:16:16 AM
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
-
 

Re:help for regular expression

graphicsxp@googlemail.com wrote:
Quote
I can't figure out what the regular expression would look like for
validating a string such as :

Lastname, Firstname
/\w+, \w+/
--
Martin Honnen
JavaScript.FAQTs.com/
-

Re:help for regular expression

On 24 Jan, 17:31, Martin Honnen <mahotr...@yahoo.de>wrote:
Quote
graphic...@googlemail.com wrote:
Quote
I can't figure out what the regular expression would look like for
validating a string such as :

Quote
Lastname, Firstname

??\w+, \w+/

--

????Martin Honnen
??? 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
-

Rehelp for regular expression}

graphicsxp@googlemail.com said:
Quote

On 24 Jan, 17:31, Martin Honnen <mahotr...@yahoo.de>wrote:
Quote
graphic...@googlemail.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 =A0JavaScript.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.
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.
--
-

Rehelp for regular expression}

graphicsxp@googlemail.com wrote:
Quote
On 24 Jan, 17:31, Martin Honnen <mahotr...@yahoo.de>wrote:
Quote
graphic...@googlemail.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:
jibbering.com/faq/
developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:RegExp
Quote
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
-

Rehelp for regular expression}

In comp.lang.javascript message <c5dc03c1-54c7-410d-8d07-aa88b8d6dac6@n2
0g2000hsh.googlegroups.com>, Thu, 24 Jan 2008 09:16:16,
graphicsxp@googlemail.com posted:
Quote

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:www.merlyn.demon.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)
-

Rehelp for regular expression}

On Jan 24, 1:20 pm, Lee <REM0VElbspamt...@cox.net>wrote:
Quote
graphic...@googlemail.com said:





Quote
On 24 Jan, 17:31, Martin Honnen <mahotr...@yahoo.de>wrote:
>graphic...@googlemail.com wrote:
>>I can't figure out what the regular expression would look like for
>>validating a string such as :

Quote
>>Lastname, Firstname

Quote
>=A0 =A0/\w+, \w+/

Quote
>--

Quote
>=A0 =A0 =A0 =A0 Martin Honnen
>=A0 =A0 =A0 =A0JavaScript.FAQTs.com/

Quote
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
-

Rehelp for regular expression}

nolo contendere said:
Quote

On Jan 24, 1:20=A0pm, Lee <REM0VElbspamt...@cox.net>wrote:
Quote
graphic...@googlemail.com said:





>On 24 Jan, 17:31, Martin Honnen <mahotr...@yahoo.de>wrote:
>>graphic...@googlemail.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 =3DA0JavaScript.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.

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.
--
-