Comments (7)
This is probably caused by the dollar escape $ inside the brackets. Ecmascript E5/E5.1 IdentityEscape production (which is the only applicable one AFAIK) is:
IdentityEscape ::
SourceCharacter but not IdentifierPart
<ZWJ>
<ZWNJ>
Because "$" is a valid IdentifierPart, the escape $ is not valid as far as I understand, and \u0024 should be instead:
var a = /[\\\^\u0024\*\+\?\|\[\]\(\)\.\{\}]/g;
There are other non-standard regexp forms that nevertheless appear in existing code. A $ escape is already accepted outside a CharacterClass but not inside it. There's an ongoing task item to allow more non-standard regexps either by default or through a feature option.
from duktape.
Thanks for this detailed explanation. I agreed, but this runs nevertheless on Chrome, Firefox and v8 command line without any configuration parameters.
from duktape.
I know - there are actually a lot of behaviors that are not standard but still work in various other engines. Being fully compatible with other engines is not a practical goal because the non-standard features of other engines are not even compatible with each other (for instance function statements, a non-standard feature, have two competing semantics; Duktape adopts the V8 semantics here).
The approach with Duktape is that the standard behavior is implemented first, and non-standard behaviors are adopted when they either fulfill an important role (like the .stack property of errors) or are crucial to compatibility. Non-standard regexp syntax is one of the latter, and it's on the work list for future releases.
from duktape.
Ok, thanks!
from duktape.
I'll add dollar escape support inside character classes into the next release as it is an easy change (and dollar escape outside is already supported). There will still unfortunately be some real world regexps that won't parse - e.g. something similar to this came up with recent Emscripten (and also the test262 test suite I think):
/^function \(\) {.*}$/
Adding support to these requires a bit more work because backtracking is needed to handle the ambiguous unquoted braces. This change will be done at some point, because these regexps do crop up with existing code bases.
from duktape.
Ok, the "dollar escape inside character class" is now in the master branch, so your original regexp should now work :-)
from duktape.
Thanks!
from duktape.
Related Issues (20)
- loading handlebars helpers HOT 1
- Is nested duk_pcall_* from the same thread supported? HOT 1
- Instructions for compiling CBOR?
- CBOR vs. JSON performance -- why is CBOR.encode so much slower than JSON.stringify? HOT 5
- An issue with breaking out of labeled blocks
- An issue with undefined and postfix operators
- stack-overflow in duktape/duk_js_call.c:1361 in duk__call_setup_act_attempt_tailcall
- stack-overflow in duktape/duk_api_stack.c:337 in duk_is_valid_posidx
- stack-overflow in duk__try_push_vsprintf in duktape/duk_api_stack.c:4800:8
- stack-overflow in duktape/duk_hobject_assert.c:215 in duk_hthread_assert_valid
- stack-overflow in duktape/duk_js_call.c:1570 in duk__call_setup_act_not_tailcall
- stack-overflow in duktape/duk_hobject_props.c:272 in duk__hobject_get_entry_object_stridx
- Security concern
- Help wanted with nested objects
- Iterating keys of proxy object HOT 1
- make file which also installs duktape fails HOT 1
- Determining when code finished execution when using duk_suspend
- Q: Bytecode only compilation flag
- Support App Privacy Manifest
- duk_create_heap_default not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duktape.