# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"""
(?: Search: \s+ (?P<SEARCH> .* ))
| (?: (?P<SHOWING> ^Showing\s.*))
| (?: ^% (?P<_TAG> (?P<SEQ> [STU] ) | (?P<PROG> [pto] ) | (?P<REST> [A-Za-z]) ) \s+
(?P<ANUMBER> A\d+) \s+ (?P<VALUE> .*) )
"""
test_str = ("# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/\n"
"## Ref: https://oeis.org/eishelp1.html\n\n"
"Search: seq:1,2,3,4\n"
"Showing 11-20 of 12439\n\n"
"%I A270929 #19 Jul 13 2023 12:28:14\n"
"%S A270929 1,2,3,4,15,20,24,32,38,40,63,93,104,194,208,514,535,600,928,1300,\n"
"%T A270929 1485,1780,2058,3060,3356,3721,6662,11552,15482,23000,27375,34748,\n"
"%U A270929 57219,61251,85221,99656,103214,103244,276537\n"
"%N A270929 Numbers k such that (16*10^k - 31)/3 is prime.\n"
"%C A270929 For k>1, numbers such that the digit 5 followed by k-2 occurrences of the digit 3 followed by the digits 23 is prime (see Example section).\n"
"%C A270929 a(40) > 3*10^5. - _Robert Price_, Jul 13 2023\n"
"%H A270929 Makoto Kamada, <a href=\"https://stdkmd.net/nrr/prime/primedifficulty.txt\">Search for 53w23.</a>\n"
"%e A270929 3 is in this sequence because (16*10^3 - 31)/3 = 5323 is prime.\n"
"%e A270929 Initial terms and primes associated:\n"
"%e A270929 a(1) = 1, 43;\n"
"%e A270929 a(2) = 2, 523;\n"
"%e A270929 a(3) = 3, 5323;\n"
"%e A270929 a(4) = 4, 53323;\n"
"%e A270929 a(5) = 15, 5333333333333323;\n"
"%e A270929 a(6) = 20, 533333333333333333323, etc.\n"
"%t A270929 Select[Range[0, 100000], PrimeQ[(16*10^# - 31)/3] &]\n"
"%o A270929 (PARI) isok(n) = ispseudoprime((16*10^n - 31)/3); \\\\ _Michel Marcus_, Mar 26 2016\n"
"%Y A270929 Cf. A056654, A268448, A269303, A270339, A270613, A270831, A270890.\n"
"%K A270929 nonn,base,more\n"
"%O A270929 1,2\n"
"%A A270929 _Robert Price_, Mar 26 2016\n"
"%E A270929 a(37)-a(38) from _Robert Price_, Mar 03 2019\n"
"%E A270929 a(39) from _Robert Price_, Jul 13 2023\n\n"
"%I A027750 #107 Sep 08 2022 08:44:49\n"
"%S A027750 1,1,2,1,3,1,2,4,1,5,1,2,3,6,1,7,1,2,4,8,1,3,9,1,2,5,10,1,11,1,2,3,4,\n"
"%T A027750 6,12,1,13,1,2,7,14,1,3,5,15,1,2,4,8,16,1,17,1,2,3,6,9,18,1,19,1,2,4,\n"
"%U A027750 5,10,20,1,3,7,21,1,2,11,22,1,23,1,2,3,4,6,8,12,24,1,5,25,1,2,13,26,1,3,9,27,1,2,4,7,14,28,1,29\n"
"%N A027750 Triangle read by rows in which row n lists the divisors of n.\n"
"%C A027750 Or, in the list of natural numbers (A000027), replace n with its divisors.\n"
"%C A027750 This gives the first elements of the ordered pairs (a,b) a >= 1, b >= 1 ordered by their product ab.\n"
"%C A027750 Also, row n lists the largest parts of the partitions of n whose parts are not distinct. - _Omar E. Pol_, Sep 17 2008\n"
"%C A027750 Concatenation of n-th row gives A037278(n). - _Reinhard Zumkeller_, Aug 07 2011\n"
"%C A027750 {A210208(n,k): k=1..A073093(n)} subset of {T(n,k): k=1..A000005(n)} for all n. - _Reinhard Zumkeller_, Mar 18 2012\n"
"%C A027750 Row sums give A000203. Right border gives A000027. - _Omar E. Pol_, Jul 29 2012\n"
"%C A027750 Indices of records are in A006218. - _Irina Gerasimova_, Feb 27 2013\n"
"%C A027750 The number of primes in the n-th row is omega(n) = A001221(n). - _Michel Marcus_, Oct 21 2015\n"
"%C A027750 The row polynomials P(n,x) = Sum_{k=1..A000005(n)} T(n,k)*x^k with composite n which are irreducible over the integers are given in A292226. - _Wolfdieter Lang_, Nov 09 2017\n"
"%C A027750 T(n,k) is also the number of parts in the k-th partition of n into equal parts (see example). - _Omar E. Pol_, Nov 20 2019\n"
"%H A027750 Franklin T. Adams-Watters, <a href=\"/A027750/b027750.txt\">Rows 1..1000, flattened</a>\n"
"%H A027750 Franklin T. Adams-Watters, <a href=\"/A027750/a027750.txt\">Rows 1..10000</a>\n"
"%H A027750 Omar E. Pol, <a href=\"http://www.polprimos.com/imagenespub/poldiv05.jpg\">Illustration of initial terms</a>, (2009).\n"
"%H A027750 Eric Weisstein's World of Mathematics, <a href=\"http://mathworld.wolfram.com/Divisor.html\">Divisor</a>\n"
"%H A027750 Wikipedia, <a href=\"http://www.wikipedia.org/wiki/Table_of_divisors\">Table of divisors</a>\n"
"%H A027750 <a href=\"/index/Di#divisors\">Index entries for sequences related to divisors of numbers</a>\n"
"%F A027750 a(A006218(n-1) + k) = k-divisor of n, 1 <= k <= A000005(n). - _Reinhard Zumkeller_, May 10 2006\n"
"%F A027750 T(n,k) = n / A056538(n,k) = A056538(n,n-k+1), 1 <= k <= A000005(n). - _Reinhard Zumkeller_, Sep 28 2014\n"
"%e A027750 Triangle begins:\n"
"%e A027750 1;\n"
"%e A027750 1, 2;\n"
"%e A027750 1, 3;\n"
"%e A027750 1, 2, 4;\n"
"%e A027750 1, 5;\n"
"%e A027750 1, 2, 3, 6;\n"
"%e A027750 1, 7;\n"
"%e A027750 1, 2, 4, 8;\n"
"%e A027750 1, 3, 9;\n"
"%e A027750 1, 2, 5, 10;\n"
"%e A027750 1, 11;\n"
"%e A027750 1, 2, 3, 4, 6, 12;\n"
"%e A027750 ...\n"
"%e A027750 For n = 6 the partitions of 6 into equal parts are [6], [3,3], [2,2,2], [1,1,1,1,1,1], so the number of parts are [1, 2, 3, 6] respectively, the same as the divisors of 6. - _Omar E. Pol_, Nov 20 2019\n"
"%p A027750 seq(op(numtheory:-divisors(a)), a = 1 .. 20) # _Matt C. Anderson_, May 15 2017\n"
"%t A027750 Flatten[ Table[ Flatten [ Divisors[ n ] ], {n, 1, 30} ] ]\n"
"%o A027750 (Magma) [Divisors(n) : n in [1..20]];\n"
"%o A027750 (Haskell)\n"
"%o A027750 a027750 n k = a027750_row n !! (k-1)\n"
"%o A027750 a027750_row n = filter ((== 0) . (mod n)) [1..n]\n"
"%o A027750 a027750_tabf = map a027750_row [1..]\n"
"%o A027750 -- _Reinhard Zumkeller_, Jan 15 2011, Oct 21 2010\n"
"%o A027750 (PARI) v=List();for(n=1,20,fordiv(n,d,listput(v,d)));Vec(v) \\\\ _Charles R Greathouse IV_, Apr 28 2011\n"
"%o A027750 (Python)\n"
"%o A027750 from sympy import divisors\n"
"%o A027750 for n in range(1, 16):\n"
"%o A027750 print(divisors(n)) # _Indranil Ghosh_, Mar 30 2017\n"
"%Y A027750 Cf. A000005 (row length), A001221, A027749, A027751, A056534, A056538, A127093, A135010, A161700, A163280, A240698 (partial sums of rows), A240694 (partial products of rows), A247795 (parities), A292226, A244051.\n"
"%K A027750 nonn,easy,tabf,look\n"
"%O A027750 1,3\n"
"%A A027750 _N. J. A. Sloane_\n"
"%E A027750 More terms from Scott Lindhurst (ScottL(AT)alumni.princeton.edu)\n")
matches = re.finditer(regex, test_str, re.MULTILINE | re.VERBOSE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html