Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
`
^source=(?P<pg_db_name>[^\s]+)\s*addon=(?P<pg_addon_name>[^\s]+)\s*sample#current_transaction=(?P<pg_transactionID>[^\s]+)\s*sample#db_size=(?P<pg_db_size>[^\s]+)\s*sample#tables=(?P<pg_numebr_of_tables>[^\s]+)\s*sample#active-connections(?P<pg_numebr_of_active_conenctions>[^\s]+)\ssample#waiting-connections=(?P<pg_numebr_of_waiting_connections>[^\s]+)\s*sample#index-cache-hit-rate=(?P<pg_index_cache_hit_rate>[^\s]+)\s*sample#table-cache-hit-rate=(?P<pg_table_cache_hit_rate>[^\s]+)\s*sample#load-avg-1m=(?P<pg_load_avg_1m>[^\s]+)\s*sample#load-avg-5m=(?P<pg_load_avg_5m>[^\s]+)\s*sample#load-avg-15m=(?P<pg_load_avg_15m>[^\s]+)\s*sample#read-iops=(?P<pg_read_iops>[^\s]+)\s*sample#write-iops=(?P<pg_write_ops>[^\s]+)\s*sample#tmp-disk-used=(?P<pg_tmp_disk_used>[^\s]+)\s*sample#tmp-disk-available=(?P<pg_tmp_disk_available>[^\s]+)\s*sample#memory-total=(?P<pg_total_memory>[^\s]+)\s*sample#memory-free=(?P<pg_free_memory>[^\s]+)\s*sample#memory-cached=(?P<pg_cached_memory>[^\s]+)\s*sample#memory-postgres=(?P<pg_memory>[^\s]+)
`
gm
^ asserts position at start of a line
source=
matches the characters source= literally (case sensitive)
Named Capture Group pg_db_name
(?P<pg_db_name>[^\s]+)
Match a single character not present in the list below
[^\s]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
addon=
matches the characters addon= literally (case sensitive)
Named Capture Group pg_addon_name
(?P<pg_addon_name>[^\s]+)
Match a single character not present in the list below
[^\s]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
sample#current_transaction=
matches the characters sample#current_transaction= literally (case sensitive)
Named Capture Group pg_transactionID
(?P<pg_transactionID>[^\s]+)
Match a single character not present in the list below
[^\s]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
sample#db_size=
matches the characters sample#db_size= literally (case sensitive)
Named Capture Group pg_db_size
(?P<pg_db_size>[^\s]+)
Match a single character not present in the list below
[^\s]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#tables=
matches the characters sample#tables= literally (case sensitive)
Named Capture Group pg_numebr_of_tables
(?P<pg_numebr_of_tables>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#active-connections
matches the characters sample#active-connections literally (case sensitive)
Named Capture Group pg_numebr_of_active_conenctions
(?P<pg_numebr_of_active_conenctions>[^\s]+)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#waiting-connections=
matches the characters sample#waiting-connections= literally (case sensitive)
Named Capture Group pg_numebr_of_waiting_connections
(?P<pg_numebr_of_waiting_connections>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#index-cache-hit-rate=
matches the characters sample#index-cache-hit-rate= literally (case sensitive)
Named Capture Group pg_index_cache_hit_rate
(?P<pg_index_cache_hit_rate>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#table-cache-hit-rate=
matches the characters sample#table-cache-hit-rate= literally (case sensitive)
Named Capture Group pg_table_cache_hit_rate
(?P<pg_table_cache_hit_rate>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#load-avg-1m=
matches the characters sample#load-avg-1m= literally (case sensitive)
Named Capture Group pg_load_avg_1m
(?P<pg_load_avg_1m>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#load-avg-5m=
matches the characters sample#load-avg-5m= literally (case sensitive)
Named Capture Group pg_load_avg_5m
(?P<pg_load_avg_5m>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#load-avg-15m=
matches the characters sample#load-avg-15m= literally (case sensitive)
Named Capture Group pg_load_avg_15m
(?P<pg_load_avg_15m>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#read-iops=
matches the characters sample#read-iops= literally (case sensitive)
Named Capture Group pg_read_iops
(?P<pg_read_iops>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#write-iops=
matches the characters sample#write-iops= literally (case sensitive)
Named Capture Group pg_write_ops
(?P<pg_write_ops>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#tmp-disk-used=
matches the characters sample#tmp-disk-used= literally (case sensitive)
Named Capture Group pg_tmp_disk_used
(?P<pg_tmp_disk_used>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#tmp-disk-available=
matches the characters sample#tmp-disk-available= literally (case sensitive)
Named Capture Group pg_tmp_disk_available
(?P<pg_tmp_disk_available>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#memory-total=
matches the characters sample#memory-total= literally (case sensitive)
Named Capture Group pg_total_memory
(?P<pg_total_memory>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#memory-free=
matches the characters sample#memory-free= literally (case sensitive)
Named Capture Group pg_free_memory
(?P<pg_free_memory>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#memory-cached=
matches the characters sample#memory-cached= literally (case sensitive)
Named Capture Group pg_cached_memory
(?P<pg_cached_memory>[^\s]+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
sample#memory-postgres=
matches the characters sample#memory-postgres= literally (case sensitive)
Named Capture Group pg_memory
(?P<pg_memory>[^\s]+)
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

`
`
gm

Test String