On 14/11/2008, Ronan Klyne <[EMAIL PROTECTED]> wrote:
> Hiro Protagonist wrote:
> > Hi all,
> >
> > I know this is, strictly speaking, off-topic. BUT, given the great
> > knowledge of people responding here, I thought I'd see if someone had
> > solved this problem before and can help....
> >
> > What I need is: a regex that shows all lines which contain 39 or less
> > commas, **with anything in between those 39 commas**. I got as far as
> > this:
> >
> > ,{38}.*,{1}
> >
> > but this has the disadvantage that it only picks up lines that start
Not so. It can start matching anywhere in the line.
It also only allows anything other than a comma after the first 38 commas.
> > with a comma - not ones that don't. I am quite bad with regular
> > expressions, so I am hoping someone can point me in the right direction.
>
>
> Your regex also has the problem that '.' will match a comma. The
> character set [^,] will match anything that's not a comma, so I think
> you want this:
>
> ([^,]*,){,39}[^,]*
>
Except that this does not disallow leading or trailing commas.
I think it needs to be:
^([^,]*,){,39}[^,]*$
>
> # r
>
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 01189 028518
> [EMAIL PROTECTED]
> www.groupbc.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]