[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Voyeur Cams | Click for more| Home]

Regex Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.
Voyeur Cams

Thread replies: 21
Thread images: 3

File: Z.jpg (14KB, 215x234px) Image search: [iqdb] [SauceNao] [Google]
Z.jpg
14KB, 215x234px
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 (584KB, 1200x900px) Image search: [iqdb] [SauceNao] [Google]
7Vdv2vB.jpg
584KB, 1200x900px
/(\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 (13KB, 664x381px) Image search: [iqdb] [SauceNao] [Google]
1448524484001.png
13KB, 664x381px
>>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 posts: 21
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.