Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?<date>\[.*?\]) (.*?) ((.|\n*)*)" Local $sString = "[2022-07-22 09:53:27,793] INFO KafkaConfig values:" & @CRLF & _ " advertised.host.name = null" & @CRLF & _ " advertised.listeners = INTERNAL://0.0.0.0:9092,BROKER://0.0.0.0:9091,CLIENT://0.0.0.0:9093" & @CRLF & _ " advertised.port = null" & @CRLF & _ " alter.config.policy.class.name = null" & @CRLF & _ " alter.log.dirs.replication.quota.window.num = 11" & @CRLF & _ " alter.log.dirs.replication.quota.window.size.seconds = 1" & @CRLF & _ " authorizer.class.name =" & @CRLF & _ " auto.create.topics.enable = true" & @CRLF & _ " auto.leader.rebalance.enable = true" & @CRLF & _ " background.threads = 10" & @CRLF & _ " broker.id = 0" & @CRLF & _ " broker.id.generation.enable = true" & @CRLF & _ " broker.rack = null" & @CRLF & _ " client.quota.callback.class = null" & @CRLF & _ " compression.type = producer" & @CRLF & _ " connection.failed.authentication.delay.ms = 100" & @CRLF & _ " connections.max.idle.ms = 600000" & @CRLF & _ " connections.max.reauth.ms = 0" & @CRLF & _ " control.plane.listener.name = null" & @CRLF & _ " controlled.shutdown.enable = true" & @CRLF & _ " controlled.shutdown.max.retries = 3" & @CRLF & _ " controlled.shutdown.retry.backoff.ms = 5000" & @CRLF & _ " controller.socket.timeout.ms = 30000" & @CRLF & _ " create.topic.policy.class.name = null" & @CRLF & _ " default.replication.factor = 1" & @CRLF & _ " delegation.token.expiry.check.interval.ms = 3600000" & @CRLF & _ " delegation.token.expiry.time.ms = 86400000" & @CRLF & _ " delegation.token.master.key = null" & @CRLF & _ " delegation.token.max.lifetime.ms = 604800000" & @CRLF & _ " delete.records.purgatory.purge.interval.requests = 1" & @CRLF & _ " delete.topic.enable = true" & @CRLF & _ " fetch.purgatory.purge.interval.requests = 1000" & @CRLF & _ " group.initial.rebalance.delay.ms = 3000" & @CRLF & _ " group.max.session.timeout.ms = 1800000" & @CRLF & _ " group.max.size = 2147483647" & @CRLF & _ " group.min.session.timeout.ms = 6000" & @CRLF & _ " host.name =" & @CRLF & _ " inter.broker.listener.name = BROKER" & @CRLF & _ " inter.broker.protocol.version = 2.3-IV1" & @CRLF & _ " kafka.metrics.polling.interval.secs = 10" & @CRLF & _ " kafka.metrics.reporters = []" & @CRLF & _ " leader.imbalance.check.interval.seconds = 300" & @CRLF & _ " leader.imbalance.per.broker.percentage = 10" & @CRLF & _ " listener.security.protocol.map = INTERNAL:PLAINTEXT,BROKER:PLAINTEXT,CLIENT:PLAINTEXT" & @CRLF & _ " listeners = INTERNAL://:9092,BROKER://:9091,CLIENT://:9093" & @CRLF & _ " log.cleaner.backoff.ms = 15000" & @CRLF & _ " log.cleaner.dedupe.buffer.size = 134217728" & @CRLF & _ " log.cleaner.delete.retention.ms = 86400000" & @CRLF & _ " log.cleaner.enable = true" & @CRLF & _ " log.cleaner.io.buffer.load.factor = 0.9" & @CRLF & _ " log.cleaner.io.buffer.size = 524288" & @CRLF & _ " log.cleaner.io.max.bytes.per.second = 1.7976931348623157E308" & @CRLF & _ " log.cleaner.max.compaction.lag.ms = 9223372036854775807" & @CRLF & _ " log.cleaner.min.cleanable.ratio = 0.5" & @CRLF & _ " log.cleaner.min.compaction.lag.ms = 0" & @CRLF & _ " log.cleaner.threads = 1" & @CRLF & _ " log.cleanup.policy = [delete]" & @CRLF & _ " log.dir = /tmp/kafka-logs" & @CRLF & _ " log.dirs = /var/lib/kafka" & @CRLF & _ " log.flush.interval.messages = 9223372036854775807" & @CRLF & _ " log.flush.interval.ms = null" & @CRLF & _ " log.flush.offset.checkpoint.interval.ms = 60000" & @CRLF & _ " log.flush.scheduler.interval.ms = 9223372036854775807" & @CRLF & _ " log.flush.start.offset.checkpoint.interval.ms = 60000" & @CRLF & _ " log.index.interval.bytes = 4096" & @CRLF & _ " log.index.size.max.bytes = 10485760" & @CRLF & _ " log.message.downconversion.enable = true" & @CRLF & _ " log.message.format.version = 2.3-IV1" & @CRLF & _ " log.message.timestamp.difference.max.ms = 9223372036854775807" & @CRLF & _ " log.message.timestamp.type = CreateTime" & @CRLF & _ " log.preallocate = false" & @CRLF & _ " log.retention.bytes = -1" & @CRLF & _ " log.retention.check.interval.ms = 300000" & @CRLF & _ " log.retention.hours = 120" & @CRLF & _ " log.retention.minutes = null" & @CRLF & _ " log.retention.ms = null" & @CRLF & _ " log.roll.hours = 168" & @CRLF & _ " log.roll.jitter.hours = 0" & @CRLF & _ " log.roll.jitter.ms = null" & @CRLF & _ " log.roll.ms = null" & @CRLF & _ " log.segment.bytes = 1073741824" & @CRLF & _ " log.segment.delete.delay.ms = 60000" & @CRLF & _ " max.connections = 2147483647" & @CRLF & _ " max.connections.per.ip = 2147483647" & @CRLF & _ " max.connections.per.ip.overrides =" & @CRLF & _ " max.incremental.fetch.session.cache.slots = 1000" & @CRLF & _ " message.max.bytes = 1000012" & @CRLF & _ " metric.reporters = []" & @CRLF & _ " metrics.num.samples = 2" & @CRLF & _ " metrics.recording.level = INFO" & @CRLF & _ " metrics.sample.window.ms = 30000" & @CRLF & _ " min.insync.replicas = 1" & @CRLF & _ " num.io.threads = 8" & @CRLF & _ " num.network.threads = 3" & @CRLF & _ " num.partitions = 1" & @CRLF & _ " num.recovery.threads.per.data.dir = 1" & @CRLF & _ " num.replica.alter.log.dirs.threads = null" & @CRLF & _ " num.replica.fetchers = 1" & @CRLF & _ " offset.metadata.max.bytes = 4096" & @CRLF & _ " offsets.commit.required.acks = -1" & @CRLF & _ " offsets.commit.timeout.ms = 5000" & @CRLF & _ " offsets.load.buffer.size = 5242880" & @CRLF & _ " offsets.retention.check.interval.ms = 600000" & @CRLF & _ " offsets.retention.minutes = 10080" & @CRLF & _ " offsets.topic.compression.codec = 0" & @CRLF & _ " offsets.topic.num.partitions = 50" & @CRLF & _ " offsets.topic.replication.factor = 1" & @CRLF & _ " offsets.topic.segment.bytes = 104857600" & @CRLF & _ " password.encoder.cipher.algorithm = AES/CBC/PKCS5Padding" & @CRLF & _ " password.encoder.iterations = 4096" & @CRLF & _ " password.encoder.key.length = 128" & @CRLF & _ " password.encoder.keyfactory.algorithm = null" & @CRLF & _ " password.encoder.old.secret = null" & @CRLF & _ " password.encoder.secret = null" & @CRLF & _ " port = 9092" & @CRLF & _ " principal.builder.class = null" & @CRLF & _ " producer.purgatory.purge.interval.requests = 1000" & @CRLF & _ " queued.max.request.bytes = -1" & @CRLF & _ " queued.max.requests = 500" & @CRLF & _ " quota.consumer.default = 9223372036854775807" & @CRLF & _ " quota.producer.default = 9223372036854775807" & @CRLF & _ " quota.window.num = 11" & @CRLF & _ " quota.window.size.seconds = 1" & @CRLF & _ " replica.fetch.backoff.ms = 1000" & @CRLF & _ " replica.fetch.max.bytes = 1048576" & @CRLF & _ " replica.fetch.min.bytes = 1" & @CRLF & _ " replica.fetch.response.max.bytes = 10485760" & @CRLF & _ " replica.fetch.wait.max.ms = 500" & @CRLF & _ " replica.high.watermark.checkpoint.interval.ms = 5000" & @CRLF & _ " replica.lag.time.max.ms = 10000" & @CRLF & _ " replica.socket.receive.buffer.bytes = 65536" & @CRLF & _ " replica.socket.timeout.ms = 30000" & @CRLF & _ " replication.quota.window.num = 11" & @CRLF & _ " replication.quota.window.size.seconds = 1" & @CRLF & _ " request.timeout.ms = 30000" & @CRLF & _ " reserved.broker.max.id = 1000" & @CRLF & _ " sasl.client.callback.handler.class = null" & @CRLF & _ " sasl.enabled.mechanisms = [GSSAPI]" & @CRLF & _ " sasl.jaas.config = null" & @CRLF & _ " sasl.kerberos.kinit.cmd = /usr/bin/kinit" & @CRLF & _ " sasl.kerberos.min.time.before.relogin = 60000" & @CRLF & _ " sasl.kerberos.principal.to.local.rules = [DEFAULT]" & @CRLF & _ " sasl.kerberos.service.name = null" & @CRLF & _ " sasl.kerberos.ticket.renew.jitter = 0.05" & @CRLF & _ " sasl.kerberos.ticket.renew.window.factor = 0.8" & @CRLF & _ " sasl.login.callback.handler.class = null" & @CRLF & _ " sasl.login.class = null" & @CRLF & _ " sasl.login.refresh.buffer.seconds = 300" & @CRLF & _ " sasl.login.refresh.min.period.seconds = 60" & @CRLF & _ " sasl.login.refresh.window.factor = 0.8" & @CRLF & _ " sasl.login.refresh.window.jitter = 0.05" & @CRLF & _ " sasl.mechanism.inter.broker.protocol = GSSAPI" & @CRLF & _ " sasl.server.callback.handler.class = null" & @CRLF & _ " security.inter.broker.protocol = PLAINTEXT" & @CRLF & _ " socket.receive.buffer.bytes = 102400" & @CRLF & _ " socket.request.max.bytes = 104857600" & @CRLF & _ " socket.send.buffer.bytes = 102400" & @CRLF & _ " ssl.cipher.suites = []" & @CRLF & _ " ssl.client.auth = none" & @CRLF & _ " ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]" & @CRLF & _ " ssl.endpoint.identification.algorithm = https" & @CRLF & _ " ssl.key.password = null" & @CRLF & _ " ssl.keymanager.algorithm = SunX509" & @CRLF & _ " ssl.keystore.location = null" & @CRLF & _ " ssl.keystore.password = null" & @CRLF & _ " ssl.keystore.type = JKS" & @CRLF & _ " ssl.principal.mapping.rules = [DEFAULT]" & @CRLF & _ " ssl.protocol = TLS" & @CRLF & _ " ssl.provider = null" & @CRLF & _ " ssl.secure.random.implementation = null" & @CRLF & _ " ssl.trustmanager.algorithm = PKIX" & @CRLF & _ " ssl.truststore.location = null" & @CRLF & _ " ssl.truststore.password = null" & @CRLF & _ " ssl.truststore.type = JKS" & @CRLF & _ " transaction.abort.timed.out.transaction.cleanup.interval.ms = 60000" & @CRLF & _ " transaction.max.timeout.ms = 900000" & @CRLF & _ " transaction.remove.expired.transaction.cleanup.interval.ms = 3600000" & @CRLF & _ " transaction.state.log.load.buffer.size = 5242880" & @CRLF & _ " transaction.state.log.min.isr = 2" & @CRLF & _ " transaction.state.log.num.partitions = 50" & @CRLF & _ " transaction.state.log.replication.factor = 3" & @CRLF & _ " transaction.state.log.segment.bytes = 104857600" & @CRLF & _ " transactional.id.expiration.ms = 604800000" & @CRLF & _ " unclean.leader.election.enable = false" & @CRLF & _ " zookeeper.connect = 0.0.0.0:2181" & @CRLF & _ " zookeeper.connection.timeout.ms = 18000" & @CRLF & _ " zookeeper.max.in.flight.requests = 10" & @CRLF & _ " zookeeper.session.timeout.ms = 6000" & @CRLF & _ " zookeeper.set.acl = false" & @CRLF & _ " zookeeper.sync.time.ms = 2000" & @CRLF & _ " (kafka.server.KafkaConfig)" & @CRLF & _ "[2022-07-22 09:53:27,840] ERROR Fatal error during SupportedServerStartable startup. Prepare to shutdown (io.confluent.support.metrics.SupportedKafka)" & @CRLF & _ "java.lang.IllegalArgumentException: requirement failed: advertised.listeners cannot use the nonroutable meta-address 0.0.0.0. Use a routable IP address." & @CRLF & _ " at scala.Predef$.require(Predef.scala:224)" & @CRLF & _ " at kafka.server.KafkaConfig.validateValues(KafkaConfig.scala:1492)" & @CRLF & _ " at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1460)" & @CRLF & _ " at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1114)" & @CRLF & _ " at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:1094)" & @CRLF & _ " at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:1091)" & @CRLF & _ " at kafka.server.KafkaConfig.fromProps(KafkaConfig.scala)" & @CRLF & _ " at io.confluent.support.metrics.SupportedServerStartable.<init>(SupportedServerStartable.java:52)" & @CRLF & _ " at io.confluent.support.metrics.SupportedKafka.main(SupportedKafka.java:45)" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH) ; 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