fent / fent/randexp.js

I think the 'control char' escapes such as \ca are not handled correctly

Open
#104 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.9k
Forks
94
PR merge metrics
No merged PRs in 30d

Description

JS regex flavour defines a set of escape codes prefixed with `\c`:

> `\cX`: Matches a control character using [caret notation](https://en.wikipedia.org/wiki/Caret_notation), where `"X"` is a letter from A–Z (corresponding to codepoints `U+0001–U+001F`). For example, `/\cM/` matches `"\r"` in `"\r\n"`.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.1

Another example:
```js
/\ca/.test('\u0001')
-> true
```

But currently it seems like RandExp treats `\ca` as "escaped `c` followed by `a`":
```js
new RandExp(/\ca/).gen()
-> "ca"

/\ca/.test("ca")
-> false
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.