T
T
Torento203452021-10-18 14:24:37
JavaScript
Torento20345, 2021-10-18 14:24:37

Why is the selected pattern not being searched?

String "hello world 2000 00:00:00 50 users"
RegExp replace(/^(\d\d:\d\d:\d\d)/g, "")
Why doesn't it delete all elements in the string except 00:00:00?

As far as I understood, what we wrote in () is a single whole, and ^in front of it means, except, i.e. replace everything except

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2021-10-21
@Torento20345

https://regex101.com/r/1mb9Jp/1

I
ikutin666, 2021-10-18
@ikutin666

not really, in this case ^ at the beginning of the line, you need to use this syntax
/[^(\d\d:\d\d:\d\d)]/g
https://regex101.com/ good site for checking regex

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question