Regular Expressions 101

Save & Share

  • Save new Regex
    ctrl+s
  • Update 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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

Code Generator

Generated Code

$re = '/(?<=\((No.\)) : )(.+)/m'; $str = 'CÔNG TY TNHH GRAB Địa chỉ (Address) :Tòa nhà Mapletree Business Centre, 1060 Nguyễn Văn Linh, Phường Tân Phong, Quận 7, Thành phố Hồ Chí Minh, Việt Nam Mã số thuế (Tax code) :0 3 1 2 6 5 0 4 3 7 HÓA ĐƠN GIÁ TRỊ GIA TĂNG (VAT INVOICE) Ký hiệu (Serial) : 1C22TGN Ngày (Date) 23 tháng (month) 05 năm (year) 2022 Số (No.) : 1117609 Mã của CQT: 00AD14CC7603364466BF60F761D05D6A13 Họ tên người mua hàng (Customer\'s name) : (Xuất bởi phần mềm EInvoice, Công ty TNHH Phát triển công nghệ Thái Sơn - MST: 0101300842 - www.einvoice.vn) Tên đơn vị (Company) :CÔNG TY TNHH UN-AVAILABLE Mã số thuế (Tax code) :0303271471 Địa chỉ (Address) :Một phần lô I/3 Đường số 7, Khu công nghiệp Vĩnh Lộc, Phường Bình Hưng Hòa B, Quận Bình Tân, TP Hồ Chí Minh, Việt Nam Hình thức thanh toán (Payment term) :Chuyển khoản Số tài khoản (Bank A/C) : STT Tên hàng hóa, dịch vụ ĐVT Số lượng Đơn giá Thuế suất Thành tiền Tiền thuế Thành tiền trước thuế (No.) (Description) (Unit) (Quantity) (Unit Price) (Tax rate) (Amount exc VAT) (VAT amount) (Selling price) A B C D E F G = I / (1+ F) H = I - G I Cước phí vận chuyển mã 1 A-3ENBVDNWWJFL Chuyến 1 9.091 10% 9.091 909 10.000 (phần doanh thu Grab được chia) Cước phí vận chuyển mã 2 A-3ENBVDNWWJFL Chuyến 1 36.364 10% 36.364 3.636 40.000 (phần doanh thu của đối tác vận tải) Tổng cộng số tiền đã có thuế GTGT: 50.000 (Total of VAT included selling price) : Tổng tiền trước thuế 10%: 45.455 Tổng tiền thuế 10%: 4.545 (Total of amount exc VAT 10%) (Total of VAT amount 10%) Trong đó: Tổng tiền trước thuế 5%: Tổng tiền thuế 5%: (in which) (Total of amount exc VAT 5%) (Total of VAT amount 5%) Tổng cộng số tiền trước thuế: 45.455 Tổng tiền thuế GTGT: 4.545 (Total of amount exc VAT) (Total of VAT amount) Số tiền viết bằng chữ (Amount in words) : Năm mươi nghìn đồng Người mua hàng (Buyer) Người bán hàng (Seller) (Ký, ghi rõ họ tên) (Ký, đóng dấu, ghi rõ họ tên) (Signature & full name) (Signature, stamp & full name) Signature Valid Ký bởi: CÔNG TY TNHH GRAB Ký ngày: 23/05/2022 Mã nhận hóa đơn (Code for checking): QIEJWLAEYGQ5 tra cứu tại (Tracking): https://vn.invoice.grab.com/ Ghi chú: Thành tiền (giá bán) là giá đã bao gồm thuế GTGT. (Note: Selling price is VAT included) (Cần kiểm tra, đối chiếu khi lập, giao, nhận hóa đơn / Need to check, compare when making, delivering, receiving invoices) Trang 1/1'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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