Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
"
(((सदनिका(.*?)(नं|नं:)(.*?))|(((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))|((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?))))(\d+))
"
gm
1st Capturing Group
(((सदनिका(.*?)(नं|नं:)(.*?))|(((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))|((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?))))(\d+))
2nd Capturing Group
((सदनिका(.*?)(नं|नं:)(.*?))|(((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))|((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?))))
1st Alternative
(सदनिका(.*?)(नं|नं:)(.*?))
3rd Capturing Group
(सदनिका(.*?)(नं|नं:)(.*?))
सदनिका
matches the characters सदनिका literally (case sensitive)
4th Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
5th Capturing Group
(नं|नं:)
1st Alternative
नं
नं
matches the characters नं literally (case sensitive)
2nd Alternative
नं:
नं:
matches the characters नं: literally (case sensitive)
6th Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
2nd Alternative
(((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))|((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?)))
7th Capturing Group
(((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))|((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?)))
1st Alternative
((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))
8th Capturing Group
((फ्लॅट|फ़्लॅट)(.*?)नंबर(.*?))
9th Capturing Group
(फ्लॅट|फ़्लॅट)
1st Alternative
फ्लॅट
फ्लॅट
matches the characters फ्लॅट literally (case sensitive)
2nd Alternative
फ़्लॅट
फ़्लॅट
matches the characters फ़्लॅट literally (case sensitive)
10th Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
नंबर
matches the characters नंबर literally (case sensitive)
11th Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
2nd Alternative
((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?))
12th Capturing Group
((फ्लॅट|फ़्लॅट)(.*?)(नं|नं.|क्र.|क्र)(.*?))
13th Capturing Group
(फ्लॅट|फ़्लॅट)
1st Alternative
फ्लॅट
फ्लॅट
matches the characters फ्लॅट literally (case sensitive)
2nd Alternative
फ़्लॅट
फ़्लॅट
matches the characters फ़्लॅट literally (case sensitive)
14th Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
15th Capturing Group
(नं|नं.|क्र.|क्र)
1st Alternative
नं
नं
matches the characters नं literally (case sensitive)
2nd Alternative
नं.
नं
matches the characters नं literally (case sensitive)
. matches any character (except for line terminators)
3rd Alternative
क्र.
क्र
matches the characters क्र literally (case sensitive)
. matches any character (except for line terminators)
4th Alternative
क्र
क्र
matches the characters क्र literally (case sensitive)
16th Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
17th Capturing Group
(\d+)
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
gm

Test String