Username: 
Password: 
Restrict session to IP 
Online within 1d

Level4 again  Go to the Training: Regex challenge

Global Rank: 4431
Totalscore: 4346
Posts: 10
Thanks: 6
UpVotes: 7
Registered: 13y 236d
fuzzy`s Avatar
Last Seen: 10y 201d
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: 8107
Totalscore: 1267
Posts: 2
Thanks: 2
UpVotes: 2
Registered: 13y 242d
Last Seen: 10y 347d
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: 566
Totalscore: 46996
Posts: 37
Thanks: 21
UpVotes: 24
Registered: 14y 25d
stormsurfer`s Avatar



Last Seen: 9y 135d
The User is Offline
RE: Level4 again
Google/translate0Thank You!2Good Post!0Bad Post! link
what do you mean capture? what is the differenct between capture and matches?
Global Rank: 814
Totalscore: 33093
Posts: 9
Thanks: 7
UpVotes: 6
Registered: 14y 150d
Last Seen: 12y 305d
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: 4431
Totalscore: 4346
Posts: 10
Thanks: 6
UpVotes: 7
Registered: 13y 236d
fuzzy`s Avatar
Last Seen: 10y 201d
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: 14815
Totalscore: 158
Posts: 1
Thanks: 0
UpVotes: 0
Registered: 9y 137d
Last Seen: 7y 360d
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, AIHAPPLE, zhukeni, alibaba2024, silenttrack, n0tHappy, nonfungiblesecurity, stormsurfer, quangntenemy, TheHiveMind, Z, balicocat, Ge0, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, fpombal, csuquvq 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 10457 times.

PHP Fatal Error(1): Constant E_STRICT is deprecated since 8.4, the error level was removed in www/protected/config.php line 6


Backtrace starts in [unknown file] line ?. GWF_Debug::shutdown_function() core/inc/util/GWF_Debug.php line 109. GWF_Debug::error_handler().... core/inc/util/GWF_Debug.php line 180.