Regex for JSON Null
Regex Pattern
^null$JSON null literal
Quick Answer
The regex pattern for json null is `^null$`. JSON null literal. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| null | ✓ Matches |
| Null | ✗ No match |
| NULL | ✗ No match |
| undefined | ✗ No match |
| nil | ✗ No match |
| None | ✗ No match |
Code Examples
javascript
const regex = /^null$/; const isValid = regex.test(value);
python
import re
pattern = r'^null$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^null$/ if value =~ pattern puts "valid" end
php
if (preg_match('/^null$/', $value)) {
echo "valid";
}java
String pattern = "^null$"; boolean isValid = value.matches(pattern);
Frequently Asked Questions
Related Regex Patterns
JavaScript Variable Name
Valid JavaScript variable/identifier name
Python Variable Name
Valid Python identifier name
CSS Class Name
Valid CSS class name (starts with letter, underscore, or hyphen)
CSS ID Selector
CSS ID selector starting with #
JSON Key
JSON object key (quoted string followed by colon)
Semantic Version (Strict)
Strict semantic versioning (MAJOR.MINOR.PATCH)