Re: Regular expression: How exclude the last \n character

Hi Ismaël,

> Every line must maximal be 50 characters long. But I want to avoid an CR is
> added to the last line. So I don't want
>
> bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
> </description>
>
> The regular expression I have now is:
>
>         ((.{0,50}\n){0,})(.{0,50})
>
> But with my editor it's still possible to enter without an error
> generation of my validator.

In the above expression, the last subgroup is allowed to be empty,
which means that it's possible for there to be no characters after the
last newline character in your element. Change it to:

  ((.{0,50}\n){0,})(.{1,50})

and your validator should complain; whether or not that changes what
you are able to enter with your editor depends on the editor.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Monday, 24 March 2003 09:12:33 UTC