chocoteam / chocoteam/choco-solver
Confusing regex behavior with letters
- Dominant language
- Java
- Stars
- 779
- Forks
- 159
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 10
Description
The Automaton class allows me to use letters in the regular expression, but then the `regular` constraint will constrain a var to be that character's ascii code _minus 7_. For example, given the constraint:
```
ICF.regular({x}, FiniteAutomaton("a"))
```
The solution will be:
```
x = 90
```
whereas I would expect 97. I see [here](https://github.com/chocoteam/choco3/blob/182c212d6607785f17737fad0eb1513a01dc9ee7/choco-solver/src/main/java/org/chocosolver/solver/constraints/nary/automata/FA/FiniteAutomaton.java#L58) that some sort of offset is built up in the mapping from chars to integers because it skips over certain special characters `]`, `[`, etc.
So I understand why this behavior is happening, but I'm curious why it must be designed this way, or if some validation (or documentation) can be implemented to help new users like me from avoiding this.
It sounds like the workaround is to replace each letter with ``, where xx is the actual ASCII code I'm looking for.
--Alex
Contributor guide
Assessment
This issue has not been assessed yet.