dokuwiki-plugin-bureaucracy
dokuwiki-plugin-bureaucracy copied to clipboard
Whitespaces in regexp
Regular expressions containing whitespaces in the literal form, e.g. ( )+ are not checked. It is necessary to use \s instead (not a severe problem, but maybe it should be documented somewhere - took me quite some time)
I have no idea what you mean. Please, could you give an example of syntax which triggers this issue, or pointer to the code you are referring?
I have a form with a textfield and a regular expression to check against. If the regular expression contains ( ) like this:
textbox "IBAN" /^[A-Z]{2}( )?\d{4}?$/
it does not check the value, I have to write it like this:
textbox "IBAN" /^[A-Z]{2}\s?\d{4}?$/
Standard regexp allows both expressions
@elaratain I believe your first example is incorrect preg RegEx, which is what Bureaucracy seems to use (I've only skim read the code).
First example should be:-
textbox "IBAN" /^[A-Z]{2}((\s)?\d{4})?$/
...unless you plan on allowing more than one space before the optional 4 digits (after the required two upper-case letters). Note that PHP supports both preg (PCRE) and ereg - it could be that Bureaucracy actually uses ereg to validate optional field parameters.
Your second example doesn't seem like it should work - I suspect I've wrongly guessed what you're trying to validate
I'm reopening this issue because I also have a problem with spaces in regex. Here's my code:
textbox "Tags" /^[A-Za-z ]+$/
There is a space character between the 'z' and the ']'
Objective : accept only space separated words
Behavior : accepts everything
Just to make sure I've tested the regex on https://regex101.com/ and it works fine....
Any idea anyone ?
BTW I've tried backslashing the space (same behavior), also if I replace the space with let's say a comma the regex works as it should. And I not want to use \s because that also allows tabs