[PathField] What is difference between maskRe, regex, stripCharsRe config option of Class CQ.form.PathField. | Community
Skip to main content
kautuk_sahni
Community Manager
Community Manager
December 2, 2015
Solved

[PathField] What is difference between maskRe, regex, stripCharsRe config option of Class CQ.form.PathField.

  • December 2, 2015
  • 4 replies
  • 2445 views

Hi Community

I was going through the documentation Link:- https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.form.PathField .

I am bit confuse between maskRe, regex, stripCharsRe config options. If some body could explain me  these three with an example.

Thanks and Regards

Kautuk Sahni

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ghhutch

maskRe is supposed to prevent certain characters from being entered into a field.  I tried to get it working on a textfield but was unsuccessful due to a JS error.  Basically you're supposed to be able to add a the property such as maskRe=/[a-zA-Z\s]*/ and this example will prevent any char other than letters and spaces from being entered into the field.

According to the docs (https://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.form.PathField):

  • maskRe : filter out keystrokes before any validation occurs

4 replies

edubey
Level 10
December 2, 2015

Hi Kautuk

regex: Take a look at my latest article published 1 hour back http://adobeaemclub.com/simple-way-to-restrict-image-type-in-pathfield-xtype/

stripCharsRe: If you want to remove some text from the value selected in Path field. To the above article if you add property with name stripCharsRe with  value /content/  . After this if you select /content/dam/geometrixx/banners/banner-mono.png, in path field you will see only dam/geometrixx/banners/banner-mono.png as you are instructing aem to strip /content/

for maskRe : I will get back to you with better example

Thanks

ghhutchAdobe EmployeeAccepted solution
Adobe Employee
December 4, 2015

maskRe is supposed to prevent certain characters from being entered into a field.  I tried to get it working on a textfield but was unsuccessful due to a JS error.  Basically you're supposed to be able to add a the property such as maskRe=/[a-zA-Z\s]*/ and this example will prevent any char other than letters and spaces from being entered into the field.

According to the docs (https://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.form.PathField):

  • maskRe : filter out keystrokes before any validation occurs
kautuk_sahni
Community Manager
Community Manager
December 7, 2015

Hi Praveen, Graham

This really help. Thank you for the detail answer. 

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
August 17, 2016

I managed to get around the error by setting maskRe as a function, like the following:

maskRe="function(){return eval('/\\\\d/')}()"

It looks like in CQ.utils.Util.formatData only the 'regex' field is evaluated, not maskRe.

Hopefully that helps someone!