^[\p{L}\p{N}]{1,50}$ >>> plus one rule

Tag: regex Author: zhangtaofly Date: 2009-08-24

I've this regex: ^[\p{L}\p{N}]{1,50}$

  • Accept all numbers and all letters
  • min length: 1
  • max length: 50

I'm trying to add this rule without success:

  • can add \s (spaces) but the text can not have only empty spaces
the space supposed to be in the middle of the string or could it be at the start/end?
Which implementation of regex are you using? Perl, Python, XML schema?
that's not python.
@SilentGhost: You're right, I read the feature table wrong. :) regular-expressions.info/refflavors.html

Best Answer

If your regular expression implementation supports look-ahead assertions:



Might not be, though. Need the OP to clarify.
@Adam Bellaire: There are many regular expression implementations that support Unicode character properties. But as far as I know, in you don’t specify the start and end in XML as it always matches the whole string.
This regex is working :) thks

Other Answer1

allow it and then trim double+ spaces

Other Answer2

Assuming it can't start with a space: