Skip to content

[BUG] #95

@ivandamyanov

Description

@ivandamyanov

Hi, I am NextJS 15.2.3 with React 19.0.0
I am wrapping OTPInput in my own custom component based on your shadcn example. I have defined a regex that allows - and _ in addition to numbers and characters

This regex works but I get a console error:
const regex = "^[a-zA-Z0-9_\-]+$"

console error: Invalid regular expression: /^[a-zA-Z0-9_-]+$/v: Invalid character in character class

This regex is valid and produces no error (I need to escape twice):
const regex = "^[a-zA-Z0-9_\\-]+$"

Is this normal behavior?

Also, sorry to ask 2 things but, even when the input is valid, before the actual input fields I get a red squiggly in empty space if I continue typing after the max number of characters as if some auto correct is triggerred, any way to fix this?

Image

Version of the library: 1.4.2

Expected Behavior

"^[a-zA-Z0-9_-]+$" - I should be able to escape with one backslash?

Current Behavior

I need to double-escape

Thank you for the amazing component!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions