+ 2
regex JS question(JavaScript)
How can I match all of a character as long as it's at the end of the value? Like Let's say I have this number I want it to only match 0s at the end of the number 167069000 It should only match the 3 zeros at the end.
8 Answers
+ 5
Calviղ The number of zeros at the end is not known though. I think this is for the factorial zeros challenge. Also, your pattern will match three zeros anywhere in the input string, not at the end. And it will include any number of random other numbers before the three zeros. This is not correct, sorry.
+ 4
Something like /[0]+$/ should do
+ 4
the two commonly used regex patterns are
^ to mark start of regex
$ to mark end of regex
so in calvin s answer I ll just add a $ in the end to make it safer as also explained by Anna
so with /\d+0{3}/
this will also select
123000123 yes
but with /\d+0{3}$/
it ll meet your specification
123000123 nope
123000 yes
+ 4
hi Daniel Cooper,
An awesome Beginners 16 vid tutorial series byThe Net Ninja
on RegEx
https://www.youtube.com/watch?v=r6I-Ahc0HB4&list=PL4cUxeGkcC9g6m_6Sld9Q4jzqdqHd2HiD
In the end you d know a lot about regex and also a demo on how to make a simple yet awesome form with client side validation using regex.
videos are short and concise, give it a try.
+ 3
/[1-9](0+)\b/
+ 2
Morpheus Thanks. I'll make sure to watch it.
+ 1
Exactly like this /\d+0{3}/ will do
+ 1
Anna is right. It's for the challenge. I'm awful at regular expressions so I decided to try out the challenge hoping to learn more about them. Also trying to learn about for loops. Lol