|
Posted by Captain Paralytic on 02/13/07 10:54
On 13 Feb, 04:06, "Bosconian" <nob...@nowhere.com> wrote:
> I have a textarea form field for inputting (or pasting) pairs of data.
>
> I need a regular expression pattern to validate each line for the following
>
> double quote
> number
> double quote
> comma
> double quote
> alpha string
> double quote
> carriage return
>
> The following comes close, but doesn't check for a carriage return at the
> end of each line:
>
> ^"([0-9]?)+"([,]\s?\"([A-Za-z0-9]+)")*$
>
> For example the following would return true:
>
> "1","John"
> "2","Paul"
> "3","George"
> "4","Ringo"
>
> Any suggestions would be appreciated.
The ? following [0-9] means that
"","John" will also be matched.
Also, the * before the $ means that
"1" will be matched
So at the very least you want
^"[0-9]+"([,]\s?\"([A-Za-z0-9]+)")$
Since a $ means "the end of the line" and since a carriage return
signifies the end of a line, his should do. Or do you want to ensure
that there is a carriage return at theend, even if there is only one
line?
[Back to original message]
|