it-tools icon indicating copy to clipboard operation
it-tools copied to clipboard

Regex tester bug

Open nyoffe-wnl opened this issue 5 months ago • 4 comments

Describe the bug

The following phone number regex seems to not work properly: ^(?\d{3})?(\s|-)?\d{3}(\s|-)?\d{4}$ I'm running it against a string of just 10 digits and it's mandating a space or hyphen for (\s|-)? when the ? should allow it to be optional.

What happened?

Image

System information

Windows 11, Vivaldi and Chrome

Where did you encounter the bug?

Public app (it-tools.tech)

nyoffe-wnl avatar Jun 09 '26 20:06 nyoffe-wnl

Hey, there's a small issue with your regex. In the pattern ^(?\d{3})?(\s|-)?\d{3}(\s|-)?\d{4}$, the (?\d{3})? part is invalid. After changing it to ^(\(\d{3}\))?(\s|-)?\d{3}(\s|-)?\d{4}$, everything works just fine.

cwm-peace avatar Jun 10 '26 06:06 cwm-peace

Hi @nyoffe-wnl @cwm-peace there may also remain a bug about non capturing groups. if you are interested in an up to date version of it-tools, with many improvements, new tools, and bug fixes, as this repo is almost no more maintained, I made a fork here : https://github.com/sharevb/it-tools (https://sharevb-it-tools.vercel.app/ and docker images https://github.com/sharevb/it-tools/pkgs/container/it-tools)

sharevb avatar Jun 10 '26 16:06 sharevb

Recommended to use kairoa: https://github.com/covoyage/kairoa. It is a cross-platform desktop application with a more modern UI and a better overall user experience.

luduoxin avatar Aug 01 '26 02:08 luduoxin

Hi @luduoxin there is indeed some interesting tool in kairoa

sharevb avatar Aug 07 '26 08:08 sharevb