c++ - Regex: Accepting space anywhere but at the beginning -
i'm working python bindings qt4.8 on os x.
- i want accept digit , few other chars , white space.
- string can empty or @ length.
- what don't want is, string being or end white space.
my working example: '[0-9pqw\+\-\*\#\(\)\.][0-9pqw\+\-\*\# \(\)\.]*'
however, don't want repeat 2 blocks 1 containing space 1 not. there should better way guess, employing [^ ], how?
second question:
- if want limit strings total length, how it?
thank you.
you use negative lookarounds @ beginning , end of pattern:
^(?![ ])[0-9pqw+*# ().-]*(?<![ ])$
note brackets not necessary aid readability. neither of escapes (as long put -
@ end).
Comments
Post a Comment