Regular Expressions 101

Save & Share

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

/
/
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/Mnemonic Code Converter(\n.*){14}\nBIP39 Mnemonic\n(.*)(\n.*){52}\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*\n.{17}(0x.{40}).*(\n.*){90}/m'; $str = ' Mnemonic Code Converter v0.5.4 Mnemonic You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word contains a checksum). For more info see the BIP39 spec. Generate a random mnemonic: 12 words, or enter your own below. Show entropy details Hide all private info Auto compute Mnemonic Language English 日本語 Español 中文(简体) 中文(繁體) Français Italiano 한국어 Čeština Português BIP39 Mnemonic name fortune horn million crop render visual rigid cup general meat cloud Show split mnemonic cards BIP39 Passphrase (optional) BIP39 Seed abdeb7185dfc09f2b500c00815017fd7af211504f3763991e4743e57c5f8a16d44ad45b8a0fdd31d26bc0891a5d8fb11e5768cceb3fe789de41562f21ef4cfd3 Coin ETH - Ethereum BIP32 Root Key xprv9s21ZrQH143K3BinS3qErRzheBdcD66eeKRzkbxCsCAhA55Dyxyr4mon9kyfvFcUsBogaqisvRKmg9x5QBwTHuWowrNjaiMTAA2chtA4Lhb Show BIP85 Derivation Path BIP32 BIP44 BIP49 BIP84 BIP141 For more info see the BIP44 spec. Purpose 44 Coin 60 Account 0 External / Internal 0 The account extended keys can be used for importing to most BIP44 compatible wallets, such as mycelium or electrum. Account Extended Private Key xprv9y5j9FgJV1k5qYaTYKSDi41ChjYs6UgLHxSEuqKEXRCpWKNNCyqa5eZ9YgUzuReAKkw4w76Ypqqu3vsEsUCUqGgyiMwhum58eqxz8myP6Ep Account Extended Public Key xpub6C55YmDCKPJP42eveLyE5BwwFmPMVwQBfBMqiDir5kjoP7hWkX9pdSsdPy1Xu875T5pXfYUkGr6nkdNBScZsoPYti5DSe7ZMM5tMwJbJYuf The BIP32 derivation path and extended keys are the basis for the derived addresses. BIP32 Derivation Path m/44\'/60\'/0\'/0 BIP32 Extended Private Key xprvA29THYcbyYXT2U7UgcQ2ByoY77HfRCjKciee9sjHgErexmAi2FGEQsZzqY12Z7YTWeUaDyQspsJgU3jLWkGnWU3EGqBvHv2u5CkyyzAUYRo BIP32 Extended Public Key xpub6F8oh49Vov5kExBwndw2Z7kGf989pfTAywaExG8uEaPdqZVrZnaUxftUgr3E1tvGTawXScmZZgyaohbNr5EriV6HqAPgBfDK83JMRKZt9Hf Derived Addresses Note these addresses are derived from the BIP32 Extended Key Encrypt private keys using BIP38 and this password: Enabling BIP38 means each key will take several minutes to generate. Use hardened addresses Table CSV Path Toggle Address Toggle Public Key Toggle Private Key Toggle m/44\'/60\'/0\'/0/0 0x797C1F428A233D36B4dAb724CCDfC25E811FCb89 0x0318c2d8977bacf98be86c03080278e5b5f32c8ecb3525a4979c0640d0501b3c98 0xea9f20a58178e9b5b0a5f2982369e7bbc134d43dae3392ea20232813be6137b5 m/44\'/60\'/0\'/0/1 0xde1F1459e6c1aDd66147a2425a430Cd057b580A5 0x0238e674eb3402a951b60374f421aade9e6878a3e5f91a7b0978b62611423dadac 0xdb08fe36f720a7ad5858b21527a80d7d0e38ede8d0e1200dca781dc14535b625 m/44\'/60\'/0\'/0/2 0xEB07A7C9d6f1F24137A06EfB8D322201345F66FA 0x03669b57aa71524d05721b626665096dd775ae3fed6f5a8a4a8236e189e43ca86e 0x96d91a864ff35104cca0972ca8368191ef5864358643e7d5c41ef53b5b31f77d m/44\'/60\'/0\'/0/3 0x3aBda96232e4c432E7025bFB414CbcB68E8227B5 0x0250243801de44f10bdd867700fc8fdb5c92d4ca3a41a2fb80a3f109fcd1eaa64a 0xcdc2013b957e2b7f577ac9a611938f0f3f9df341f4edf54eb70c297979a9d517 m/44\'/60\'/0\'/0/4 0x664c13e4365113F89A5138C8a215A8E300c47866 0x035ff6ffc5dea92c089af8ed50cde70de33b3ae9c36645e2b1d8afdc894733cbbb 0xaecf3b37d6f379f2cfe7d7beeacca904d46524160701927d75dd68ee6be5541c m/44\'/60\'/0\'/0/5 0xBaBbF254FED92208aF2499d76DB4e7e9d394B493 0x02c9f0cdb9c3caba2af0827afb4b30b969a61bbcb65835cedd3dd411183400a5d6 0xa9a06474547d22218f9b02d33be31727d8592e48fc8b20daa6f9ac4ecca45eaf m/44\'/60\'/0\'/0/6 0x5A7707aec34BB81Ade56DCcbd46DC3159A3582F1 0x02dfbe6de2509126827f9bcfb093acb5ed2fd35ba605196c36c7db34258b58e347 0x60c6ba8f1e95e67cdbdc68e207650ad07b4dabedba2707e42c8596033062e9f8 m/44\'/60\'/0\'/0/7 0xE715A766Ea102BBcAD55e226B8b9Ae42015D4A98 0x02d399f4bce504210238b66669a8a22655fcd4ade44629f9e9115dd268ccede5c6 0xff01bfcbfb2f7fc75b6c45333a6b2e0b67adf158cc72433c3409547947d848f6 m/44\'/60\'/0\'/0/8 0xB57A91429EEf9a6f37832492DCd6Df436AFDC67F 0x022ab4a66e4e4092af27de19f9348bde6f0b2256ec395ff31079d2ff17898b1880 0x5dcc824e37f591f42cbc10b89f8c32f26730119b8e22c08f2b2b2934fe4221a3 m/44\'/60\'/0\'/0/9 0x894d0afb01208Acf939Fc7909c16Cb246fB67d87 0x033fe9c26732c3b338c32b64a92c3ab366daaa5acd27d9f8e3bcdf817f3f85479e 0x1f27c9c621e7352559a47feeeb495252da646dd9701b3d73736d03bd0e8627c4 m/44\'/60\'/0\'/0/10 0x9ADFfD8BDe6A362A1F4FB8e14A48884fB9E92cb2 0x039117ac096449503d04e35887093107919b16b28bace2e7d930bd27f4dbe3de25 0xbccd749921a5b4694bbba40f963904c56812427ce2ab313069b127c6219bc584 m/44\'/60\'/0\'/0/11 0xE656A66a0f6A59fb720a5aB915ec9e02aaFD6Bc5 0x029d61fb707314a807986a6a5b3c29974bf1661cee292ff57f4399fb95080d5e51 0x2ed8c5132f7a2be1955f32c6b53df30eb1c2a77ee6837914834e118f17c138b2 m/44\'/60\'/0\'/0/12 0x8B01F645eB33e2a974F1EE5f7D0ec0338d303Ab9 0x02fb78c6d20816d1035c5c636988c9f55686bc635821e88106db9c7ae364728cb0 0x4e81a2bf09e51cadf49546fc4a74de21206f6b19577ad681b7cb2cb9c3b50add m/44\'/60\'/0\'/0/13 0x87c2cCCC71f17708d8f315c5C6475d050E772e6c 0x03a37b13dfe249e06ea19e98ec42b429fc74521a3df13654bdd7dc7c10448e42c7 0xf58cd6e8094897f55bfce2298b3e443361db474f047b97579b56c8330e5f25fd m/44\'/60\'/0\'/0/14 0x00824a4848469386090CB91D1D8d795a29C0a705 0x0318895bf18abd9378fa4fe657cc0145cdf0da065df72e3e8cddfc4782c2a78207 0x49b43846d2a214d0f6b54b1e44babd60bcf529a7dd0e3c1ac61eb39b9da35eaf m/44\'/60\'/0\'/0/15 0xa6F267259A9E83AA053C408873869d0cB2FD9239 0x03c7803dd1c91ff718318b7909a81279afb0c15eb1179a214045b10f303f116aee 0x20792e57ec3ba7fd347b3b1893b9d9ebe8857a96d1b0e5f90423c178443b9b8c m/44\'/60\'/0\'/0/16 0xE2b9357e513669E97c63959Ae10C0c758cd17f7F 0x02a30905515b81f1b47003dd9b0a9e3c6dfee196a67db4f0f4fa3cfa7332becdad 0x24522352e6204ead7b2720bde055b847d8234e8a1a81c32707a64fe17ab3ef32 m/44\'/60\'/0\'/0/17 0x704E87fb48D3695f4519f06d131021415fd8602F 0x03e76be165f3dbb1509c5542457b831432551d7f9e3ef89eb0c57cad8eaa6b64dd 0x702f4ec4564a2f6757c1136d8360c527ef4e9018d2f3c3f5e5955c2193051ddd m/44\'/60\'/0\'/0/18 0x1041FBdC030262689add18294521716bd95C081C 0x02581f3e4dc997972a27e4acb5f9baa64b97d099edc9872be1a3e13d0177d9300a 0xd4645461ce6f27daa73215b5d88fa433c2bb88ef70b003d7de742978c9c859fb m/44\'/60\'/0\'/0/19 0x485715036FA08F4a54Ee1aE802D0dDf159Eb9950 0x03b3f32cbd6173db6130459c56b0761ff269713b31c339803293db485254f3d017 0x839213219133738a4438b3e5e647597ff15b537627520e796eadd9d969b9f335 Show 20 more rows starting from index (leave blank to generate from next index) More info BIP39 Mnemonic code for generating deterministic keys Read more at the official BIP39 spec BIP32 Hierarchical Deterministic Wallets Read more at the official BIP32 spec See the demo at bip32.org BIP44 Multi-Account Hierarchy for Deterministic Wallets Read more at the official BIP44 spec BIP49 Derivation scheme for P2WPKH-nested-in-P2SH based accounts Read more at the official BIP49 spec BIP85 Deterministic Entropy From BIP32 Keychains Read more at the official BIP85 spec Entropy Entropy values should not include the BIP39 checksum. This is automatically added by the tool. Entropy values must be sourced from a strong source of randomness. This means flipping a fair coin, rolling a fair dice, noise measurements etc. Do NOT use phrases from books, lyrics from songs, your birthday or street address, keyboard mashing, or anything you think is random, because chances are overwhelming it isn\'t random enough for the needs of this tool. Do not store entropy. Storing entropy (such as keeping a deck of cards in a specific shuffled order) is unreliable compared to storing a mnemonic. Instead of storing entropy, store the mnemonic generated from the entropy. Steganography may be beneficial when storing the mnemonic. The random mnemonic generator on this page uses a cryptographically secure random number generator. The built in random generator can generally be trusted more than your own intuition about randomness. If cryptographic randomness isn\'t available in your browser, this page will show a warning and the generate button will not work. In that case you might choose to use your own source of entropy. You are not a good source of entropy. Card entropy has been implemented assuming cards are replaced, not drawn one after another. A full deck with replacement generates 232 bits of entropy (21 words). A full deck without replacement generates 225 bits of entropy (21 words). Card entropy changed significantly from v0.4.3 to v0.5.0. The old version can be accessed at https://github.com/iancoleman/bip39/releases/tag/0.4.3 or https://web.archive.org/web/20201018232020/https://iancoleman.io/bip39/ PBKDF2 What is PBKDF2 (Password Based Key Derivation Function 2) ? Please refer to this wikipedia article for more detail. Mail about PBKDF2 security here. Wallet software that implement BIP39 only use 2048 iterations as a norm. Increasing this parameter will increase security against brute force attack, but you will need to store this new parameter. However, as long as you back up your BIP39 seed there will not be risk to lost your fund. To access them with custom PBKDF2 iterations, use this file (or other) to compute your targeted BIP39 seed. Using less than 2048 PBKDF2 iterations is insecure without strong optional BIP39 Passphrase. License Please refer to the software license for more detail. The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Alternative Tools This tool is interoperable with any BIP39 wallet. Some similar tools to this one (ie not consumer wallets) are https://bip32jp.github.io/english/ Offline Usage You can use this tool without having to be online. In your browser, select file save-as, and save this page as a file. Double-click that file to open it in a browser on any offline computer. Alternatively, download the file from the latest GitHub release - https://github.com/iancoleman/bip39/releases/latest/ This project is 100% open-source code Get the source code from the repository - https://github.com/iancoleman/bip39 Libraries BitcoinJS - https://github.com/bitcoinjs/bitcoinjs-lib jsBIP39 - https://github.com/iancoleman/jsbip39 sjcl - https://github.com/bitwiseshiftleft/sjcl jQuery - https://jquery.com/ Twitter Bootstrap - http://getbootstrap.com/'; $subst = "$2\n$4\n$5\n$6\n$7\n$8\n$9\n$10\n$11\n$12\n$13"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php