A
A
Anton89892022-01-28 17:00:07
Regular Expressions
Anton8989, 2022-01-28 17:00:07

What should the regular expression look like?

Good afternoon, how to make a regular expression for checking &1234577934 (starts with & and then a number)
I tried this const reg = /^$|\&?\d$/ - does not work ((

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2022-01-28
@Stalker_RED

And you insert your regular into https://regex101.com/ and there it will be written on the side how it works.
You have a lot of weird and unnecessary checks.
Enough&\d+

S
SOTVM, 2022-01-29
@sotvm

probably it is necessary to have word boundaries, otherwise it will not highlight the word but its part,
for example: abc &123
\b&\d+\b tried, but something does not work?
Threat
to breathe like this \B&\d+\b
https://regex101.com/r/3yDtDi/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question