{"video_id":"5vbk0TwkokM","comment_count":45,"fetched_at":"2026-10-23T18:39:33+00:00","source":"innertube_next","comments":[{"id":"Ugy5Fua2gijXgbQoFiR4AaABAg","text":"Take your personal data back with Incogni! Use code standupmaths at the link below and get 60% off an annual plan: https://incogni.com/standupmaths\n\nDon’t use code ^.?$|^(..+?)\\1+$.","author":"@standupmaths","author_id":"UCSju5G2aFaWMqn-_0YBtq5A","like_count":528,"published_time":"1 year ago"},{"id":"Ugxu8q3_UtnnWnBWSRx4AaABAg","text":"The plural of regex is regrets.","author":"@Graphene_314","author_id":"UCJjZgIMeEOLI2aNiRs6iT_A","like_count":4,"published_time":"1 year ago"},{"id":"UgwaEXiEz9crdtFoRhN4AaABAg","text":"10:25 you are actually using the number but in base 1.","author":"@Chelo_m","author_id":"UCUarEV1bCsaoUhc1_Pb8t3w","like_count":4,"published_time":"1 year ago"},{"id":"Ugx2qpOpGqBhxIG6mGZ4AaABAg","text":"Regular expressions are already scary by nature. Making one that produces primes is truly terrifying.","author":"@Yogarine","author_id":"UCS2ajc9eSEE2UY3ws0SSU5w","like_count":3,"published_time":"1 year ago (edited)"},{"id":"Ugx6cCNadFH5d_hPQiR4AaABAg","text":"No, it's not sieve of Erathostenes, it's just naive trial subtraction. By \"subtraction\" I mean it effectively performs division by repeatedly subtracting the divisor and hoping to get 0, rather than by using any of the better division algorithms. By \"naive\" I mean it tries divisors up to n instead of sqrt(n). And did I mention that each individual subtraction is linear time in in the divisor? All of this means that for every divisor tried, every character in the string is processed, and the complexity is o(n²). This is the bubblesort of primality tests. But it's still cool!","author":"@Axacqk","author_id":"UCMMehsEKw_OeJMONpwDlzzg","like_count":0,"published_time":"1 year ago (edited)"},{"id":"UgxYu44FhEZOqUakYGZ4AaABAg","text":"6:07 I think you mean begin with an m and end with an s","author":"@extremepayne","author_id":"UCGaPq14IfgZ89MEG8emh_zA","like_count":6,"published_time":"1 year ago"},{"id":"UgyUA9lHlVIFneNMoXl4AaABAg","text":"Regular expressions are otherworldly. Do learn them if you do any programming, though; they are one of the most useful things you can master.","author":"@kingbeauregard","author_id":"UCPE4Z-DGzZtSf7RlsL2D5pA","like_count":7,"published_time":"1 year ago"},{"id":"UgyWSqKi5__VZDNbPTJ4AaABAg","text":"just to be that guy: 127.0.0.1 isn't \"home\", it's loopback, so it should just send you back to where you're at right now.","author":"@CheaterCodes","author_id":"UCdy9fjHQerBicemLBGUbDxQ","like_count":1,"published_time":"1 year ago"},{"id":"Ugy9-sxLS2JlOd7NOy14AaABAg","text":"12:26  1 is not prime?","author":"@TheAwes0meo","author_id":"UCGB7BUAHxEwQX9X2v_Qcy_A","like_count":0,"published_time":"1 year ago"},{"id":"UgyVq5YngE1oGtYn9cl4AaABAg","text":"Also works as '^.$|^(...*)\\1+$' if you want to be different :)","author":"@blazethefaith","author_id":"UCI57Vxfj9ysAi19Lum1tLFA","like_count":1,"published_time":"1 year ago"},{"id":"UgwBgM8Eh9UOvdJLlfl4AaABAg","text":"wow, what a neat trick! i'm adding this to my production code immediately, good luck new hires!","author":"@Cmanorange","author_id":"UC4knWqb_6Ikc8PAOG3ltUJw","like_count":4,"published_time":"1 year ago"},{"id":"UgwcRklhfAeyvPTreop4AaABAg","text":"What in the ^.?$|^(..+?)\\1+$ did I just watch?\n\nEdit: Added","author":"@Rohanology27","author_id":"UCJ9lagRtTa9r0DuVt06eJjg","like_count":765,"published_time":"1 year ago (edited)"},{"id":"UgzHzbPPZd71HAmdinJ4AaABAg","text":"If have a problem, and you try to use regex to solve it, you now have two problems.","author":"@LuxFerre4242","author_id":"UCCfsgNdYf-iXDLbbHJCsTlg","like_count":582,"published_time":"1 year ago"},{"id":"Ugw-Hju7Uanjulxq6hh4AaABAg","text":"Which Python editor/IDE is this","author":"@amits4744","author_id":"UCqBmyXJ_3QRX17FRyK6rpwA","like_count":0,"published_time":"1 year ago"},{"id":"Ugy5ImuA4fb6Pw2ccR14AaABAg","text":"It's just a regular expression! :( There are older and much more mysterious incantations to conjugate prime numbers.\r\nFor example this one {(2=+⌿0=(⍳⍵)∘.|⍳⍵)/⍳⍵} M will make all prime numbers appear up to M.\nAnd it's a mathematical language since 1957-1962, not just an expression, even a regular one.","author":"@cret859","author_id":"UCbs2Ui3Hi6FsOCLI4cZ08nw","like_count":0,"published_time":"1 year ago"},{"id":"UgwhjkbAZa_Tku_RyDp4AaABAg","text":"Haven't even watched the video yet but looks like major regex BS.","author":"@dean117","author_id":"UCKIRzM9waGlg-RH4s1PV-cw","like_count":0,"published_time":"1 year ago"},{"id":"UgyVa6p4bWmqnx9Qgi94AaABAg","text":"I don't think I've ever heard somebody pronounce the 'g' in 'regex' like the 'g' in 'regular', even though it obviously makes sense when you think about it.","author":"@sevcoyote4730","author_id":"UCj01_Ui8O532gCjZU5kpQVw","like_count":41,"published_time":"1 year ago"},{"id":"UgwSChHtGEM8lrgrzW94AaABAg","text":"I loved the home joke at the end; you're such a good localhost.","author":"@scottieapplseed","author_id":"UCdf47DeDBhUuOpO45mOzmgA","like_count":288,"published_time":"1 year ago"},{"id":"UgxTXJmAXlCpFUnwzG94AaABAg","text":"'^' is called a caret. An up-arrow would be ↑...","author":"@decare696","author_id":"UCZ3baSKRGrY2IkSCyhnj5Eg","like_count":34,"published_time":"1 year ago"},{"id":"Ugwp4ODQZGTpMHcV_e54AaABAg","text":"Who tf created a lenguage no one can read naturally??","author":"@pedropiata648","author_id":"UCtoq_e5j253ACnqomA_4Eqw","like_count":0,"published_time":"1 year ago"},{"id":"UgzqU0bMJ9YIJUQU3Sd4AaABAg","text":"To simplify, this takes the number and expresses it as a unary numeral system, where the number of marks is the value of the number you put in (e.g. 1 is 1, 2 is 11, 3 is 111, ...). The regex then looks to divide the unary representation into exactly N groups of size M, where both N and M are natural numbers with value 2 or larger. For example, you can divide 4 (represented as 1111) into 2 groups of \"11\". You can divide 6 (represented 111111) into 2 groups of \"111\" or 3 groups of \"11\". However, you can't divide 3 (represented as 111) into groups of the same size (technically you can do 3 groups of \"1\", but then M isn't 2 or larger).  Basically, you are checking if the number has any factors bigger than 1, which obviously is only false for prime numbers.","author":"@RMDragon3","author_id":"UCp5W7nDSov0UxmKhXfpCruQ","like_count":321,"published_time":"1 year ago (edited)"},{"id":"Ugy5hEqqbEAXdFiA2l14AaABAg","text":"love that the halloween horror episode on a math channel is . . . code","author":"@tempest_dawn","author_id":"UCE_Zd3u43KXcvc6VeK9dxZQ","like_count":1,"published_time":"1 year ago"},{"id":"UgynaR5eBS6J0roO3wd4AaABAg","text":"15+ years of programming experience including using regular expressions and I still watched and enjoyed this video. It's a testament to Matt's enthusiasm and his skill as a speaker/teacher.","author":"@busyfreeguy","author_id":"UCYb6I6itHs549WleqRzTB5A","like_count":892,"published_time":"1 year ago"},{"id":"Ugxsv3PtuN-b6VvZgrN4AaABAg","text":"1:00 how is that regular😭😭😭😭😭😭","author":"@LucasUngerl","author_id":"UCs582r2oawvHWzFm4898syA","like_count":5,"published_time":"1 month ago"},{"id":"Ugz7jhhntWlVsG6HJOF4AaABAg","text":"Matt: \"What the factor?\"\nPrimes: \"Your factors can't help you here.\"","author":"@tostadojen","author_id":"UCfYBH6Iq8K__KQ-kLTauIag","like_count":56,"published_time":"1 year ago"},{"id":"Ugy0szHRRYa359SSKL54AaABAg","text":"Regex is already halloween worthy.","author":"@mckseal","author_id":"UCME_FCm6JpYft5uEgs-N4fg","like_count":1,"published_time":"1 year ago"},{"id":"UgytLXncylhfuU_gjzF4AaABAg","text":"To clarify: a '?' on it's own matches 0 or 1 of the preceding character. A '?' following '+' modifies the greedy behavior of '+' to be less greedy","author":"@aeroeng15","author_id":"UCMAFg0Op6zaFRW4nsF1NFEA","like_count":512,"published_time":"1 year ago"},{"id":"UgxLLuTYJ9FYU_D5vbd4AaABAg","text":"I love regular expressions. I taught myself to use them in college and then as an intern doing data entry I was able to complete a full day's \"work\" in like 30 minutes.","author":"@linguica","author_id":"UCL9glIt5C6CaIA25xXE74Kw","like_count":12,"published_time":"1 year ago"},{"id":"UgwWBC_iFx-KkQ3Neyd4AaABAg","text":"Welp, here is what ChatGPT said after I gave it the expression with no context\n\nBreaking down the regex\n\nI’m focusing on the alternation operator '|' to divide the regex into two distinct parts, analyzing each component to understand the overall pattern it matches.\n\nBreaking down regex patterns:\n\n^.?$ matches empty or single-character strings.\n^(..+?)\\1+$ captures and repeats a non-greedy two-character sequence.\nExamining capture groups\n\nOK, let me see. I’m trying to grasp the syntax (..+?) in regex, where it matches any character followed by one or more, non-greedy, and I’m curious about its functionality.\n\nBreaking down the syntax\n\nI’m working through the syntax of (..+?), which likely matches two characters or more, with the first being any character and the second being one or more characters, non-greedy.\n\nUnderstanding the match\nI’m piecing together a regex pattern that identifies strings starting with a character group, followed by repeated groups, each at least two characters long.\n\nBreaking down the regex\n\nStarting with ^.?$, which matches strings of length 0 or 1. Hurts my head because \"abcabcabc\" fits neither.\n\nMoving to ^(..+?)\\1+$, which focuses on capturing groups. For \"abcabcabc\", it captures 'ab' and checks for repeated groups, but no matches appear.\n\nExamining the match\n\n. +? matches 'ab', and \\1+ extends the match to include repetitions of 'ab'. This approach ensures consistent identification of 'ab' throughout the string, even with interruptions.\n\nTesting regex capabilities\n\nI’m experimenting with the regex against 'ababab' and observing that the capture group effectively identifies 'ab'. However, 'abcabcabc' fails to match unless the capture group is extended or '.+?' accommodates more characters.\n\nAdjusting my approach\n\nI’m starting with a longer capture group and non-greedy matching to match 'abcabcabc'. The group initially matches 'ab' but not 'c'. Non-greedy matching might account for this.\n\nClarifying regex\n\nI’m thinking through whether 'aa' matches the regex. The capture group \\1+ needs at least one repetition of 'aa', but none exists. Progressing through, I’m piecing together the need for repetition in the regex pattern.\n\nTaking a closer look\n\nI’m analyzing whether the regex can handle 'aa'. With \\1+ outside the capture group and a non-greedy match requirement inside, it seems 'aa' might be too short.\n\nTesting regex width\n\nOK, let's see if 'aaa' aligns with the regex. The capture group snagged 'aa' and now \\1+ needs to match more 'aa'. Hm, that's interesting because 'aaa' doesn't have enough 'aa's to continue matching.\n\nUnderstanding non-greedy patterns\n\nI’m learning about non-greedy pattern matching, where '.+?' captures the smallest possible match and can expand if necessary. This approach is not suitable for strings shorter than four characters.\n\nAnalyzing regex patterns\n\nRefining pattern match\n\nOK, let's see. The regex matches strings of length 0 or 1, or strings with a repeated substring of at least 2 characters. Excludes strings like 'aa' and 'aaa'.\n\nClarifying regex nuances\n\nI'm working through a regex that matches strings of length 0 or 1, or strings with a repeated substring of at least 2 characters. This covers both empty strings and those with non-primitive repetitions.\n\nUnderstanding non-greedy matching\n\nI’m digging into the non-greedy regex pattern ('.+?'), which aims to capture minimal characters while enabling the rest of the pattern to match. This results in aligning with either an empty string, a single character, or a repeated substring of at least two characters.","author":"@Herc08","author_id":"UCCEB4meUmvOFZ0z--JxCK6A","like_count":1,"published_time":"1 year ago"},{"id":"Ugx-wQPSrJ6jYx2MWgd4AaABAg","text":"A bit pedantic, but 127.0.0.1 is a loopback address. It's like stepping outside to ring the doorbell to make sure it is working. The only time it sends you home is if you are already home.","author":"@KnightTobyas","author_id":"UCZWhBrq8UQZ0gyea3psENTQ","like_count":404,"published_time":"1 year ago"},{"id":"Ugzg-WnPKqtO8cvrinN4AaABAg","text":"Someone has to say it. Regular expressions,in their truest sense, ie ones that are equivalent to regular languages are not capable of primality test. Only extended ones that have “memory” can do it. I.e \\1 part of the example above is what’s not possible in regular languages","author":"@arthurmesh7884","author_id":"UC58YSxONtNx5pVQiln10frQ","like_count":507,"published_time":"1 year ago (edited)"},{"id":"UgwUkfZsK3Khivf6JT54AaABAg","text":"This regular expression has been around for decades. Attributed to Abigail, a Dutch JAPH (just another Perl hacker). I hope YT will not eat my comment.","author":"@Slowphoton","author_id":"UCYI5thTaBef4vkHbw2FM4gg","like_count":10,"published_time":"1 year ago"},{"id":"UgzyDJkWvrgSY1oa2GB4AaABAg","text":"Sorry to point this out - this isn't a regex.  Regular expressions themselves are not powerful enough to calculate primes.  This is an extension to regular expressions that makes it turing complete.","author":"@johnflux1","author_id":"UC-1L6gSrFl75aGNy3igi1zw","like_count":2,"published_time":"1 year ago"},{"id":"Ugx67l80xd1H0_zKDKp4AaABAg","text":"A minor bit of pedantry: ^.?$|^(..+?)\\1+$ is a \"regex\" (i.e. a pattern specification understood by most common implementations of regular-expression-based pattern-matching engines), but it is not a regular expression in the strict sense of the term. The minimal definition of a strict regular expression includes only literal characters, a symbol standing for an empty string (typically ε), parentheses to clarify the order of operations, the alternation operator (vertical bar), and the Kleene star (asterisk). Most of the other symbols in our prime-matching regex can be derived from those in the minimal definition: The wildcard . is shorthand for (a|b|c|d|...), and a+ is shorthand for aa*. The symbols ^, $, and ? are irrelevant in a strict regular expression, since it either matches the entire string or it doesn't match at all. The real problem is the \\1: There's no way to construct an equivalent out of the minimal definition.","author":"@sillybear25","author_id":"UCe7rEyX4m17_QBjxJeaF7KA","like_count":75,"published_time":"1 year ago"},{"id":"Ugx6Qyqw-T3RVvgGv5Z4AaABAg","text":"13:45 Hey! Regex capture groups are zero-indexed; the brackets start at one but capture group zero is the entire match. Don't you slander regular expressions by calling them one-indexed","author":"@estivalbloom","author_id":"UCKQpx1ZrWGBRefkXAOb8dPg","like_count":301,"published_time":"1 year ago"},{"id":"UgxzpBrD30cVjgMTVxV4AaABAg","text":"Just in terms of brevity, the question marks are not needed so the shorter version would be:\n^.$|^(..+)\\1+$","author":"@quaji1","author_id":"UCvLTAerBoYStVhlG7osNXig","like_count":0,"published_time":"1 year ago"},{"id":"Ugxq8uQVlySlWw17FD94AaABAg","text":"I realized at 2:39 how it must work and shouted O M G, it just looks for a repetition of any number of chars, which is exactly the prime sieve of Eratosthenes. So 1000 is really fast since it matches (..){500} early on.  Okay on to the rest of the video to see if I was right ...","author":"@xorbe2","author_id":"UCcUHKgjog_rgpOzMHSTzomA","like_count":5,"published_time":"1 year ago"},{"id":"UgxJXUzNon2d3GjRd9t4AaABAg","text":"\"What the factor\" got me hahaha","author":"@masterandexpert288","author_id":"UCTRMHG_xLi-1fP_D6yFJ_pQ","like_count":89,"published_time":"1 year ago"},{"id":"Ugwp0KYMf7AGbCz7gXN4AaABAg","text":"I love regular expressions. The xkcd is true, you really do feel like you've developed a super power when you master them","author":"@tonicblue","author_id":"UCXYgIqbgaehNP4MuehAuFfA","like_count":47,"published_time":"1 year ago"},{"id":"Ugwe66xKmF8NfqeQnpB4AaABAg","text":"There's no place like 127.0.0.1 ... except the rest of the /8 block of 16,777,216 addresses also reserved for loopback","author":"@CoolAsFreya","author_id":"UCvk6Dn39IdAk6OI4_Zkjg2w","like_count":120,"published_time":"1 year ago"},{"id":"UgyNT8dUcPXL8wT_jgZ4AaABAg","text":"3:31 The ability of Matt to accurately point to symbols that he'll put in later...","author":"@stephenj9470","author_id":"UCZFPqM_ZloTuQfNaHaB5AhA","like_count":150,"published_time":"1 year ago"},{"id":"UgxxRtL-aF1gAKy1bnt4AaABAg","text":"i love matts videos \nmaths videos are the best","author":"@stoopidgenious","author_id":"UCCdsY_08WbykpVcDEqHBCnw","like_count":117,"published_time":"1 year ago"},{"id":"Ugym0dPVdUpgodb__pp4AaABAg","text":"This looks like an alternate version of Abigail's prime regex that was posted on a Perl newsgroup in the '90s. Legendary Perl hacker.","author":"@CurtisDyer","author_id":"UCivoqKtkXkmrSgq80U4yexg","like_count":64,"published_time":"1 year ago"},{"id":"UgweelWDmbNw94YBLl94AaABAg","text":"13:48 This is not technically a \"regular\" expression because backreferences are not regular; as what the backreference matches changes based on previous input, and regular expressions are context-free (you can concatenate two regular expressions and it has the expected effect, but this does not hold true if the expression contains a backreference). \"Regular\" is an important property because it guarantees performance within a fixed amount of memory regardless of the input size, and compute time proportional to the input size, but the backreference obliterates that characteristic.","author":"@austinwright2591","author_id":"UCV0mna0o3mWVJlHz4JVjR2g","like_count":13,"published_time":"1 year ago (edited)"},{"id":"UgxSGVwSF0HduaoAZuB4AaABAg","text":"A string is a \"string of characters\". It makes sense to say because it applies to all strings, not just those that also happen to be grammatically correct sentences. For example \"^.?$|^(..+?)\\1+$\" is a string, but certainly not a sentence.","author":"@Thewinner312","author_id":"UCEmL7ufgNhckNBxQwn1j6BA","like_count":7,"published_time":"1 year ago"}],"deduped_at":"2026-10-25T20:45:33+00:00"}