JRS: In article <11**********************@75g2000cwc.googlegroups. com>,
dated Mon, 14 Aug 2006 06:19:25 remote, seen in
news:comp.lang.javascript,
sa*************@googlemail.com posted :
>I'd like to use regular expression for checking validity of a field.
What would be the expression for :
firstname, lastname, organisation23
so basically, a string + comma then another string + comma then a
alphanumeric string
Maybe no : better a commaless string + comma then another commaless
string + comma then a string; and ignoring whitespace between elements
if you use, say, .match to get the three elements.
Only of it is impossible for the organisation name to contain a comma
(or other non-alphanumeric) would your description serve,
Consider the case of
St = "James, Smith, Mart-Wal & sons, Inc."
M = St.match(/^([^,]+),\s*([^,]+),\s*(.+$)/)
No match : M = null
Match : M[1]..M[3] are the fields.
<URL:http://www.merlyn.demon.co.uk/js-valid.htm>
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.