[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Regex Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 21
Thread images: 3
File: Z.jpg (14 KB, 215x234) Image search: [Google]
Z.jpg
14 KB, 215x234
Can you guys make a regular expression to search/match with dubs.
>>
\d+(00|11|22|33|44|55|66|77|88|99)
>>
>>51533793

^dubs$
>>
>>51533834
OP here, you fucked up it doesn't catch dubs
>>
File: 7Vdv2vB.jpg (584 KB, 1200x900) Image search: [Google]
7Vdv2vB.jpg
584 KB, 1200x900
/(\d)\1$/
>>
>>51533793
(\d)\1$
>>
i wrote a thing that would find all the dubs, trips, etc... in a number range. here's the function that checked if characters repeated:

def dubChecker(n):
check=str(n)
for i in range(len(check),1,-1):
if len(set(check[-i:]))==1:
return i
return n

you could change
return n
to
return False
or something if you wanted to make it less ambiguous, but a single-digit integer should be sufficiently clear and allows you to use a dict that maps 3: trips, 2: dubs, etc...
>>
if (postNumber == 00000000) ...
else if (postNumber = 00000011)...
else if (postNumber = 00000022)...
...
else if (postNumber = 99999999)...
>>
>>51534200
Was going to call you stupid for str in range, but actually a clever use of len of str to quickly get digit size!
>>
>>51534047
> not knowing how RegEx work
Stop being stupid anytime.
>>
>>51534262
Its always nice to meet a fellow CS grad
>>
>>51533793
/[[:checkem:]]/
>>
>>51534262
I see you made a typo where you're assigning to postNumber instead of checking for equality. I'm going to need you to go ahead and manually correct all 10,000,000 typos.
>>
File: 1448524484001.png (13 KB, 664x381) Image search: [Google]
1448524484001.png
13 KB, 664x381
>>51533793
<?php
function dubs($postNumber) {
if(!is_int($postNumber) || $postNumber < 10) return false;
list($n1,$n2) = sscanf(strrev($postNumber), "%01d%01d");
return $n1 === $n2;
}
?>
>>
>>51534315
i felt like the intuition of getting the length of the set was a little cleverer (since repeating digits will always resolve to a single-element set), but thanks
>>
>>51534566
Nice fatal error, faggot. Might as well do what your process did and kill yourself.
>>
>>51534674
don't hurt yourself on that edge, kid
>>
\d+(\d)\1
>>
>>51535575
Thanks for not fucking up
>>
\d{2}
>>
>>51533834
Dumbass
Thread replies: 21
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.