Username: 
Password: 
Restrict session to IP 

Level4 again  Go to the Training: Regex challenge

Global Rank: 2763
Totalscore: 4520
Posts: 10
Thanks: 4
UpVotes: 5
Registered: 4y 221d
fuzzy`s Avatar
Last Seen: 1y 186d
The User is Offline
Level4 again
Google/translate0Thank You!0Good Post!0Bad Post! link
/^wechall4?(?=\.(jpg|gif|tiff|bmp|png)$)/


Can you help me find why this regex is incorrect?
Are there any incorrect cases which can bypass it?

I've tested it and it captures only filename (with or without 4) and only with specified extension.

Thanks for help! Smile
Global Rank: 4864
Totalscore: 1180
Posts: 2
Thanks: 2
UpVotes: 2
Registered: 4y 227d
Last Seen: 1y 332d
The User is Offline
RE: Level4 again
Google/translate1Thank You!1Good Post!0Bad Post! link
It doesn't capture filename, it matches filename and extension and additionally captures extension without the dot. You must to capture filename and only filename.

Edit.
Seems that you tested it wrong. ;)
Last edited by pskosinski - Mar 14, 2013 - 00:12:29
Global Rank: 421
Totalscore: 48708
Posts: 37
Thanks: 18
UpVotes: 19
Registered: 5y 9d
stormsurfer`s Avatar



Last Seen: 120d 12h
The User is Offline
RE: Level4 again
Google/translate0Thank You!1Good Post!0Bad Post! link
what do you mean capture? what is the differenct between capture and matches?
Global Rank: 565
Totalscore: 35722
Posts: 9
Thanks: 7
UpVotes: 5
Registered: 5y 134d
Last Seen: 3y 290d
The User is Offline
RE: Level4 again
Google/translate2Thank You!2Good Post!0Bad Post! link
i see two problems whith your regex:
- you have two groups. one should be enough...
- how do you start a non-capturing group? hint: it's not ?=

capturing is done using capturing groups. that means if a string matches the pattern, then parts of that string can be captured using capturing groups...
Global Rank: 2763
Totalscore: 4520
Posts: 10
Thanks: 4
UpVotes: 5
Registered: 4y 221d
fuzzy`s Avatar
Last Seen: 1y 186d
The User is Offline
RE: Level4 again
Google/translate1Thank You!1Good Post!0Bad Post! link
Finally completed this task. Thanks for help guys! Smile
Global Rank: 7635
Totalscore: 79
Posts: 1
Thanks: 0
UpVotes: 0
Registered: 122d 11h
Last Seen: 99d 12h
The User is Offline
RE: Level4 again
Google/translate0Thank You!0Good Post!0Bad Post! link
Quote from sutupud
Mar 14, 2013 - 01:29:32

i see two problems whith your regex:
- you have two groups. one should be enough...
- how do you start a non-capturing group? hint: it's not ?=

capturing is done using capturing groups. that means if a string matches the pattern, then parts of that string can be captured using capturing groups...


Why isn't it "?="?
My regex works fine on online demos, but I can't just get it to work on this challenge
"?:" Doesn't seem to have any effect on those demos
Redknee, tunelko, silenttrack, qdxy, stormsurfer, TheHiveMind, Z, Ge0, samuraiblanco, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123 have subscribed to this thread and receive emails on new posts.
1 people are watching the thread at the moment.
This thread has been viewed 6214 times.