MaskedTextBox: How to create a regular expression that allows to enter space characters?

Editors for WPF Forum

Posted 9 years ago by Peter Schregle
Version: 14.2.0611
Avatar

Hi, I cannot find a way to create a regular expression that allows to enter a space character. How can I do that?

Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

A "\s" will allow any whitespace (including tabs, etc.) but if you want space only, I believe that you could do "[ ]" (without quotes).


Actipro Software Support

Posted 9 years ago by Peter Schregle
Avatar

Thanks for the information. I did not find this in the reference documentation. Did I look in the wrong place? Is there some place in the documentation, where the regular expression syntax you are using is documented?

It works somehow. However, I found that I need to enter the space in the edit control as Ctrl-Space, just hitting the Space key alone does not work. Is there a way to make the Space key work?

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

There is info about the mask syntax in this topic "Actipro Editors / Other Controls / MaskedTextBox".  It doesn't look like we mention that whitespace is ignored there, so we'll add a note on that for the next version.

I modified our MaskedTextBox Masks QuickStart and added this predefined mask as a test:

new PredefinedMask(@"\d+[ ]\d", "Test")

It allows digits followed by a space and then a digit.  That seemed to work fine with the space key for me.  Are you able to repro the space not working in this sample with a different mask?  Please let us know ASAP since we are about to push out the 2015.1 version.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.