3 ms·
Anchors (208): k$ Ranges (202): ^[a-f]+$ Backrefs (199): (\w{3}).*\1
by shdon 13y ago
Anchors (208):
k$
Ranges (202):
^[a-f]+$
Backrefs (199):
(\w{3}).*\1
- gorhill 13y agoBackrefs (201): (...).*\1
- selmnoo 13y agoWait, so what's with the 'point system' here? Why's shdon answer for backrefs 199 and yours 201? (and while you're at it, could you briefly explain (...).*\1 for the regex newbies?)
- taylorfausak 13y ago"You are deducted one point per character you use, and ten if you match something you shouldn't."
- josso 13y agoRegex explained: (...) # Match exactly 3 (the dots) characters and save them as a group (the parenthesis) .* # Match any character (the dot) 0 or more times (the asterisk) \1 # Reuse the first group
- pyed 13y agobackreferencing is new to me, but why this: (...).*(...) isn't working !! ain't I back referencing the first group which is (...) ?
- josso 13y agoIt isn't working because (...) is just matching 3 characters. What your regex is saying, is basically: Match any 3 characters, then any character 0 or more times, then any 3 characters. You're reusing the regex and not the match. Back referencing essentially means that you'll match whatever is matched the first time, rather than reusing the regex pattern. I hope that made a little sense. Grouping, capturing, matching and backreferences is part of what makes regex tricky and very powerful. You might want to use some of the online tools, which can help explain the regex visually.
- pyed 13y agothanks for clearing that for me, I figured it out my self after giving it sometime.
- deleted 13y ago[deleted]