Comments

kaidawai’s picture

Hi,

is it realy an issue?
\u is afaik not used as escape in php, did i miss it somhow?
afaik it is either \x... or \p{...}. both are still supported.

see:
http://www.php.net/manual/en/regexp.reference.unicode.php

attiks’s picture

fapi_validation uses this

    'fapi_validation_rule_alpha' => '/^[\pL]++$/uD',
    'fapi_validation_rule_alpha_numeric' => '/^[\pL\pN]++$/uD',
kaidawai’s picture

yes, but( note the backslash): '\u nnn' and its /part of the expression/.
the '/u' (note the slash, is the delimiter) in the above regex is a /flag/ which tells php to go to utf8 mode. that was a problem i told you before at clientside_validation which was introduced with the switch to 2.0. it now throws an exception. solution strip it of or add u as a empty flag to xregxp. but that is an issue with clientside_validation.
see also: http://drupal.org/node/1584902#comment-6006298

attiks’s picture

Status: Active » Fixed

Fixed in clientside validation

slevithan’s picture

This only removed support for \u{N...}. JS/XRegExp still supports \uNNNN without the curly braces, and XRegExp still supports \p{name}. Plus, as @kaidawai said, PCRE doesn't use \u{N...} anyway.

If you want XRegExp to support PCRE's \x{N...}, that's easy to add as long as you only care about the Unicode BMP (i.e., code points up to FFFF). See http://xregexp.com/api/#addToken . Essentially, it would be something like this (untested):

XRegExp.install('extensibility');
XRegExp.addToken(
/\\x\{([0-9a-fA-F]{1,4})\}/,
function (match) {
var str = match[1];
while (str.length < 4) str = '0' + str;
return '\\u' + str;
},
{scope: 'all'}
);

attiks’s picture

Title: Unicode removed » Add support for PCRE \x
Category: task » feature
Status: Fixed » Active

@slevithan, I misread it the first time

Turning this into a feature to add support for \x

kaidawai’s picture

I thought about this one.

first off \p{} exists so imo you can express everything. so it is not crucial.

maybe an idea to get this + other stuff in might be to create an xregxp addon, put next to the other addons, that contains this \x extension and some other stuff that make live easier. so whoever needs that can additionally load it. means no codechange to the drupal module itself.
i look into it in a couple of days.

kaidawai’s picture

StatusFileSize
new832 bytes

I looked into this again. It realy makes little sence to re- introduce \u{},
It would re introduce more problems than it solves. Plus: it doesn'concern the Issue.

Regexes like the ones mentioned need support for the shortform \pL of p{L} and possesive quantifiers need to be converted in greedy ones(which has a performance penalty).
You find a js addon attached that seems to make such expressions work(i had to add a txt extention to upload it. That means a lot of FAPI Builtin should work with that - provided unicode support is also loaded.

kaidawai’s picture

Status: Active » Fixed
StatusFileSize
new1.14 KB

Hi,
attaches is a cleaner version of an addon that solves the problems. As everything can be expressed with alternative regular expressions that work in PHP as well as with XRegExp it will not be included in the 7.x module for now. It is however included with the 6.x module and documented here for possible future use or whoever might want to use it...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.