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

/
/

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/\/\*(.|\n|\r)*\*\//'; $str = ' package es.elcorteingles.ns.integrations.schema.omnistoreordernotification._2_0; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * Contiene informacion del coste a nivel de * ShippingGroup. * - Importe total. * - Importe pendiente a cobrar. * - Importe * del gasto de envío * * * <p>Java class for ShippingGroupPriceInfoType complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="ShippingGroupPriceInfoType"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="totalCost" type="{http://www.elcorteingles.es/ns/integrations/schema/OmniStoreOrderNotification/2_0}AmountType" minOccurs="0"/> * &lt;element name="pendingCost" type="{http://www.elcorteingles.es/ns/integrations/schema/OmniStoreOrderNotification/2_0}AmountType" minOccurs="0"/> * &lt;element name="shippingCost" type="{http://www.elcorteingles.es/ns/integrations/schema/OmniStoreOrderNotification/2_0}AmountType" minOccurs="0"/> * &lt;element name="groupDiscountsAmount" type="{http://www.elcorteingles.es/ns/integrations/schema/OmniStoreOrderNotification/2_0}AmountType" minOccurs="0"/> * &lt;element name="totalNetAmount" type="{http://www.elcorteingles.es/ns/integrations/schema/OmniStoreOrderNotification/2_0}AmountType" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ShippingGroupPriceInfoType", propOrder = { "totalCost", "pendingCost", "shippingCost", "groupDiscountsAmount", "totalNetAmount" }) public class ShippingGroupPriceInfoType { protected AmountType totalCost; protected AmountType pendingCost; protected AmountType shippingCost; protected AmountType groupDiscountsAmount; protected AmountType totalNetAmount; /** * Gets the value of the totalCost property. * * @return * possible object is * {@link AmountType } * */ public AmountType getTotalCost() { return totalCost; } /** * Sets the value of the totalCost property. * * @param value * allowed object is * {@link AmountType } * */ public void setTotalCost(AmountType value) { this.totalCost = value; } /** * Gets the value of the pendingCost property. * * @return * possible object is * {@link AmountType } * */ public AmountType getPendingCost() { return pendingCost; } /** * Sets the value of the pendingCost property. * * @param value * allowed object is * {@link AmountType } * */ public void setPendingCost(AmountType value) { this.pendingCost = value; } /** * Gets the value of the shippingCost property. * * @return * possible object is * {@link AmountType } * */ public AmountType getShippingCost() { return shippingCost; } /** * Sets the value of the shippingCost property. * * @param value * allowed object is * {@link AmountType } * */ public void setShippingCost(AmountType value) { this.shippingCost = value; } /** * Gets the value of the groupDiscountsAmount property. * * @return * possible object is * {@link AmountType } * */ public AmountType getGroupDiscountsAmount() { return groupDiscountsAmount; } /** * Sets the value of the groupDiscountsAmount property. * * @param value * allowed object is * {@link AmountType } * */ public void setGroupDiscountsAmount(AmountType value) { this.groupDiscountsAmount = value; } /** * Gets the value of the totalNetAmount property. * * @return * possible object is * {@link AmountType } * */ public AmountType getTotalNetAmount() { return totalNetAmount; } /** * Sets the value of the totalNetAmount property. * * @param value * allowed object is * {@link AmountType } * */ public void setTotalNetAmount(AmountType value) { this.totalNetAmount = value; } } '; $subst = ""; $result = preg_replace($re, $subst, $str, 1); 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