Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • 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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
No Match

"
"
gm

Test String

Code Generator

Generated Code

re = /(^\d{4}-\d{2}-\d{2} \d{1,2}:\d{2}:\d{2},\d{3}) (FATAL|ERROR|WARN|INFO|DEBUG) \[(\S*)\] \[(\S*)\] (\S*) - ((?:(?!^[0-9]{4}(?:-[0-9]{2}){2}(?:[^|\r?\n]+){3}).*(?:\r?\n)?)+)/m str = '2022-05-05 12:44:05,122 INFO [NotFromActor] [test-cluster-akka.actor.default-dispatcher-4] com.thatdot.quine.persistor.ExceptionWrappingPersistenceAgent - Persistence backend for core quine data is at Version(12.0.0), this is usable as-is by Version(12.0.0) 2022-05-05 12:44:05,185 INFO [akka://test-cluster@localhost:10001/user/graph-service] [test-cluster-akka.actor.default-dispatcher-39] com.thatdot.quine.graph.GraphClusterActor - CurrentClusterState(TreeSet(), Set(), Set(), None, Map()) 2022-05-05 12:44:05,193 INFO [NotFromActor] [test-cluster-akka.actor.default-dispatcher-39] com.thatdot.quine.persistor.ExceptionWrappingPersistenceAgent - Persistence backend for Quine Enterprise app state is at Version(1.1.0), this is usable as-is by Version(1.1.0) 2022-05-05 12:44:06,475 INFO [akka://test-cluster@localhost:10001/user/graph-service] [test-cluster-akka.actor.default-dispatcher-39] com.thatdot.quine.graph.GraphClusterActor - RequestGraphClusterCommitment at: QuineHost(localhost,10001) as member: 1 for shards: List(4, 5, 6, 7) 2022-05-05 12:44:06,477 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - QuineHost(localhost,10001) is adding a new local shard at idx: 4 to shard map: TrieMap() 2022-05-05 12:44:06,481 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - QuineHost(localhost,10001) is adding a new local shard at idx: 5 to shard map: TrieMap(4 -> LocalShardRef(Actor[akka://test-cluster/user/shard-4#1793439195])) 2022-05-05 12:44:06,481 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - QuineHost(localhost,10001) is adding a new local shard at idx: 6 to shard map: TrieMap(5 -> LocalShardRef(Actor[akka://test-cluster/user/shard-5#1810283]), 4 -> LocalShardRef(Actor[akka://test-cluster/user/shard-4#1793439195])) 2022-05-05 12:44:06,481 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - QuineHost(localhost,10001) is adding a new local shard at idx: 7 to shard map: TrieMap(5 -> LocalShardRef(Actor[akka://test-cluster/user/shard-5#1810283]), 6 -> LocalShardRef(Actor[akka://test-cluster/user/shard-6#1102949325]), 4 -> LocalShardRef(Actor[akka://test-cluster/user/shard-4#1793439195])) 2022-05-05 12:44:06,547 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.ClusterInterface - QuineHost(localhost,10001) is setting new state to: ClusterStateRecord(FullyConfigured,Milliseconds(1651779846513)) Prior history: [ClusterStateRecord(MemberStarting,Milliseconds(1651779845171))] 2022-05-05 12:44:06,548 INFO [akka://test-cluster@localhost:10001/user/graph-service] [test-cluster-akka.actor.default-dispatcher-12] com.thatdot.quine.graph.GraphClusterActor - AnnounceClusterState(ClusterStateRecord(FullyConfigured,Milliseconds(1651779846513)),ClusterOperationConfig(Map(0 -> HostActorOpt(QuineHost(localhost,10000),Some(Actor[akka://test-cluster@localhost:10000/user/graph-service#445140876])), 1 -> HostActorOpt(QuineHost(localhost,10001),Some(Actor[akka://test-cluster/user/graph-service#-1798402774])), 2 -> HostActorOpt(QuineHost(localhost,10002),Some(Actor[akka://test-cluster@localhost:10002/user/graph-service#-1382095132]))),List(QuineHost(localhost,10003), QuineHost(localhost,10004)),4,test-cluster,3,Some(QuineHost(localhost,10000)))) on: localhost:10001 2022-05-05 12:44:06,559 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10000/), Path(/user/shard-0)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10002/), Path(/user/shard-10)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10000/), Path(/user/shard-1)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10002/), Path(/user/shard-9)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10000/), Path(/user/shard-2)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10000/), Path(/user/shard-3)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10002/), Path(/user/shard-11)] 2022-05-05 12:44:06,560 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-41] com.thatdot.quine.graph.GraphCluster - Trying to resolve shard for actor selection: ActorSelection[Anchor(akka://test-cluster@localhost:10002/), Path(/user/shard-8)] 2022-05-05 12:44:06,607 INFO [NotFromActor] [test-cluster-akka.quine.graph-shard-dispatcher-40] com.thatdot.quine.graph.ClusterInterface - QuineHost(localhost,10001) is setting new state to: ClusterStateRecord(Operating,Milliseconds(1651779846580)) Prior history: [ClusterStateRecord(FullyConfigured,Milliseconds(1651779846513)), ClusterStateRecord(MemberStarting,Milliseconds(1651779845171))] 2022-05-05 12:44:06,607 INFO [akka://test-cluster@localhost:10001/user/graph-service] [test-cluster-akka.actor.default-dispatcher-12] com.thatdot.quine.graph.GraphClusterActor - AnnounceClusterState(ClusterStateRecord(Operating,Milliseconds(1651779846580)),ClusterOperationConfig(Map(0 -> HostActorOpt(QuineHost(localhost,10000),Some(Actor[akka://test-cluster@localhost:10000/user/graph-service#445140876])), 1 -> HostActorOpt(QuineHost(localhost,10001),Some(Actor[akka://test-cluster/user/graph-service#-1798402774])), 2 -> HostActorOpt(QuineHost(localhost,10002),Some(Actor[akka://test-cluster@localhost:10002/user/graph-service#-1382095132]))),List(QuineHost(localhost,10003), QuineHost(localhost,10004)),4,test-cluster,3,Some(QuineHost(localhost,10000)))) on: localhost:10001 2022-05-05 12:54:56,494 WARN [SinkRefStageImpl(akka://test-cluster)] [test-cluster-akka.actor.default-dispatcher-33] akka.stream.impl.streamref.SinkRefStageImpl - [SinkRef-839] Stream already completed before remote side materialized, failing now. 2022-05-05 12:56:39,137 WARN [SinkRefStageImpl(akka://test-cluster)] [test-cluster-akka.actor.default-dispatcher-37] akka.stream.impl.streamref.SinkRefStageImpl - [SinkRef-14261] Stream already completed before remote side materialized, failing now. 2022-05-05 12:56:50,781 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-35] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 10000 edges 2022-05-05 12:57:13,931 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-42] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 20000 edges 2022-05-05 12:57:33,425 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-37] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 30000 edges 2022-05-05 12:57:53,088 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-33] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 40000 edges 2022-05-05 12:58:12,422 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-12] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 50000 edges 2022-05-05 12:58:31,107 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-37] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 60000 edges 2022-05-05 12:58:49,985 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-4] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 70000 edges 2022-05-05 12:59:08,559 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-36] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 80000 edges 2022-05-05 12:59:26,979 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-4] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 90000 edges 2022-05-05 12:59:46,073 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-42] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 100000 edges 2022-05-05 13:00:05,268 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-38] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 110000 edges 2022-05-05 13:00:25,051 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-34] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 120000 edges 2022-05-05 13:00:44,851 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-36] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 130000 edges 2022-05-05 13:01:04,730 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-38] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 140000 edges 2022-05-05 13:01:24,253 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-38] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 150000 edges 2022-05-05 13:01:44,088 WARN [akka://test-cluster@localhost:10001/user/shard-4/FFF77323397A9001] [test-cluster-akka.actor.default-dispatcher-35] com.thatdot.quine.graph.NodeActorPlus - Node: -2406679665012735 has: 160000 edges' # Print the match result str.scan(re) do |match| puts match.to_s end

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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html