Regular Expressions 101

Json Starts With Keys

Open Workspace
  • PCRE2 (PHP)
  • Match
0

Regular Expression

/
^\{[\s]*\"(tab1|tab3|tab5)".*
/
gm

Description

Regex for checking if JSON starts with desired keys Useful for validating/filtering database entries when used in combination with SQL Like

Example:

Postgre: select * from table_name where column_json ~ '^{[\s]"(tab1|tab3|tab5)".'

Submitted by MUA