I get a strange error "invalid qualifier" ... can someone help me?
html
& lt; Input type = "text" value = "5 + 5" id = "test" />
JS
up = {}; Up ['2'] = new array (); Up ['2'] ['CMD'] = '# (\ - | \ | | * | | / |) [0- 9] (, | [0- 9] |) (\ - | \ + | \ * | \ /) [0-9] #gi '; Var inp_val = $ ('# test'). Val (); If (inp_val.match (up ['2'] ['CMD'])) {$ ('body'). Append ('& lt; br / & gt; ok'); }
In javascript, should be written as a regular expression
Var re = / thepatterns / mod;
i.e.
ups = {}; Up ['2'] = new array (); Up ['2'] ['CMD'] = / (\ - | \ | | * | | / |) [0- 9] (, | [0- 9] |) (\ - | \ + | * | / / [[0-9] / gi;
In addition, it simplified it as
ups = {2: {cmd: / ([- + * / /)) Can be [, \ D]?) ([- + * \ /]) \ d / g}};
The reason for the invalid quantifier is that, unlike PHP, a \
is the result of an unfamiliar character without that character \
:
- JavaScript
'\ p \ q' == 'pq'
- PHP
'\ p \ Q '==' \\ p \\ q '
Therefore, your string will be defined as
. + | * | / |) [0-9] (, | [0- 9] |) (- | + | * | /) [0- 9] #gi '
An invalid Reggae Because +
(a quantifier) is not before any pattern.
Comments
Post a Comment