Closed (fixed)
Project:
XRegExp API
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 May 2012 at 10:36 UTC
Updated:
19 Apr 2013 at 13:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
kaidawai commentedHi,
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
Comment #2
attiks commentedfapi_validation uses this
Comment #3
kaidawai commentedyes, 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
Comment #4
attiks commentedFixed in clientside validation
Comment #5
slevithan commentedThis 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'}
);
Comment #6
attiks commented@slevithan, I misread it the first time
Turning this into a feature to add support for \x
Comment #7
kaidawai commentedI 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.
Comment #8
kaidawai commentedI 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.
Comment #9
kaidawai commentedHi,
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...