Single number regex

Hello everyone
i’m trying to write a code where my only problem is to search for a specific number, single digit, without any repetition , and this number may or may not be there with make it more hard.
i tried : /^(1){1}\s/ , /[1]{1}\s/ , [1{1}]\s/ , /[1-1]\s/ , /\d{1}\s/ and tried all of them with {1,1} .
i would appreciate any help[https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/telephone-number-validator]
this is my code,
(https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/telephone-number-validator)

What happens if you try,

d*?

Quantifiers - JavaScript | MDN

my proplem is that the number is not at the end ,it’s actually the first of few but i don’t know how search for a single one at the start .

^d*?

The carat means ‘begins with’ as I recall.

i updated the post with a link ,pleas take a look if you have some time

How about,

/^[1]?/

syntax error ,nothing to repeat ,and that’s the case with many other attempts

What happens if you add a space character at the end.

1 Like

finaly ,it worked ,thank you very much ,i was going crazy over this :sweat_smile:

1 Like