Regular Expressions 101

Community Patterns

snake case

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(\w*)\s(\w*)
/
gm

Description

What is snake case?

Snake case is a naming convention in which a developer replaces spaces between words with an underscore.

Snake case examples

Here are three simple examples of code in the snake case naming convention:

  • increase_count_by_one
  • materials_procurement
  • material_warehousing

regular expression

  1. match: /(\w+)\s(\w+)/
  2. replace: \L$1_\$2
Submitted by Moonshadow2333 - 2 years ago (Last modified 2 years ago)