Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
No Match

r"""
"""
gmx

Test String

Code Generator

Generated Code

re = /(?: 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> .*) ) /mx str = '# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ ## Ref: https://oeis.org/eishelp1.html Search: seq:1,2,3,4 Showing 11-20 of 12439 %I A270929 #19 Jul 13 2023 12:28:14 %S A270929 1,2,3,4,15,20,24,32,38,40,63,93,104,194,208,514,535,600,928,1300, %T A270929 1485,1780,2058,3060,3356,3721,6662,11552,15482,23000,27375,34748, %U A270929 57219,61251,85221,99656,103214,103244,276537 %N A270929 Numbers k such that (16*10^k - 31)/3 is prime. %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). %C A270929 a(40) > 3*10^5. - _Robert Price_, Jul 13 2023 %H A270929 Makoto Kamada, <a href="https://stdkmd.net/nrr/prime/primedifficulty.txt">Search for 53w23.</a> %e A270929 3 is in this sequence because (16*10^3 - 31)/3 = 5323 is prime. %e A270929 Initial terms and primes associated: %e A270929 a(1) = 1, 43; %e A270929 a(2) = 2, 523; %e A270929 a(3) = 3, 5323; %e A270929 a(4) = 4, 53323; %e A270929 a(5) = 15, 5333333333333323; %e A270929 a(6) = 20, 533333333333333333323, etc. %t A270929 Select[Range[0, 100000], PrimeQ[(16*10^# - 31)/3] &] %o A270929 (PARI) isok(n) = ispseudoprime((16*10^n - 31)/3); \\\\ _Michel Marcus_, Mar 26 2016 %Y A270929 Cf. A056654, A268448, A269303, A270339, A270613, A270831, A270890. %K A270929 nonn,base,more %O A270929 1,2 %A A270929 _Robert Price_, Mar 26 2016 %E A270929 a(37)-a(38) from _Robert Price_, Mar 03 2019 %E A270929 a(39) from _Robert Price_, Jul 13 2023 %I A027750 #107 Sep 08 2022 08:44:49 %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, %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, %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 A027750 Triangle read by rows in which row n lists the divisors of n. %C A027750 Or, in the list of natural numbers (A000027), replace n with its divisors. %C A027750 This gives the first elements of the ordered pairs (a,b) a >= 1, b >= 1 ordered by their product ab. %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 %C A027750 Concatenation of n-th row gives A037278(n). - _Reinhard Zumkeller_, Aug 07 2011 %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 %C A027750 Row sums give A000203. Right border gives A000027. - _Omar E. Pol_, Jul 29 2012 %C A027750 Indices of records are in A006218. - _Irina Gerasimova_, Feb 27 2013 %C A027750 The number of primes in the n-th row is omega(n) = A001221(n). - _Michel Marcus_, Oct 21 2015 %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 %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 %H A027750 Franklin T. Adams-Watters, <a href="/A027750/b027750.txt">Rows 1..1000, flattened</a> %H A027750 Franklin T. Adams-Watters, <a href="/A027750/a027750.txt">Rows 1..10000</a> %H A027750 Omar E. Pol, <a href="http://www.polprimos.com/imagenespub/poldiv05.jpg">Illustration of initial terms</a>, (2009). %H A027750 Eric Weisstein\'s World of Mathematics, <a href="http://mathworld.wolfram.com/Divisor.html">Divisor</a> %H A027750 Wikipedia, <a href="http://www.wikipedia.org/wiki/Table_of_divisors">Table of divisors</a> %H A027750 <a href="/index/Di#divisors">Index entries for sequences related to divisors of numbers</a> %F A027750 a(A006218(n-1) + k) = k-divisor of n, 1 <= k <= A000005(n). - _Reinhard Zumkeller_, May 10 2006 %F A027750 T(n,k) = n / A056538(n,k) = A056538(n,n-k+1), 1 <= k <= A000005(n). - _Reinhard Zumkeller_, Sep 28 2014 %e A027750 Triangle begins: %e A027750 1; %e A027750 1, 2; %e A027750 1, 3; %e A027750 1, 2, 4; %e A027750 1, 5; %e A027750 1, 2, 3, 6; %e A027750 1, 7; %e A027750 1, 2, 4, 8; %e A027750 1, 3, 9; %e A027750 1, 2, 5, 10; %e A027750 1, 11; %e A027750 1, 2, 3, 4, 6, 12; %e A027750 ... %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 %p A027750 seq(op(numtheory:-divisors(a)), a = 1 .. 20) # _Matt C. Anderson_, May 15 2017 %t A027750 Flatten[ Table[ Flatten [ Divisors[ n ] ], {n, 1, 30} ] ] %o A027750 (Magma) [Divisors(n) : n in [1..20]]; %o A027750 (Haskell) %o A027750 a027750 n k = a027750_row n !! (k-1) %o A027750 a027750_row n = filter ((== 0) . (mod n)) [1..n] %o A027750 a027750_tabf = map a027750_row [1..] %o A027750 -- _Reinhard Zumkeller_, Jan 15 2011, Oct 21 2010 %o A027750 (PARI) v=List();for(n=1,20,fordiv(n,d,listput(v,d)));Vec(v) \\\\ _Charles R Greathouse IV_, Apr 28 2011 %o A027750 (Python) %o A027750 from sympy import divisors %o A027750 for n in range(1, 16): %o A027750 print(divisors(n)) # _Indranil Ghosh_, Mar 30 2017 %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. %K A027750 nonn,easy,tabf,look %O A027750 1,3 %A A027750 _N. J. A. Sloane_ %E A027750 More terms from Scott Lindhurst (ScottL(AT)alumni.princeton.edu) ' # Print the match result str.scan(re) do |match| puts match.to_s end

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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html