Regex for Cron Expression (6-field Quartz)
Regex Pattern
^(?:[0-9*,/-]+\s+){5}[0-9*,/?L#-]+$6-field Quartz/Spring cron expression with seconds
Quick Answer
The regex pattern for cron expression (6-field quartz) is `^(?:[0-9*,/-]+\s+){5}[0-9*,/?L#-]+$`. 6-field Quartz/Spring cron expression with seconds. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 0 0 12 * * ? | ✓ Matches |
| */5 * * * * * | ✓ Matches |
| 0 0 0 1 1 * | ✓ Matches |
| * * * * * | ✗ No match |
| invalid cron | ✗ No match |
| * * * * | ✗ No match |
Code Examples
javascript
const regex = /^(?:[0-9*,\/-]+\s+){5}[0-9*,\/?L#-]+$/;
const isValid = regex.test(value);python
import re
pattern = r'^(?:[0-9*,/-]+\s+){5}[0-9*,/?L#-]+$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^(?:[0-9*,/-]+\s+){5}[0-9*,/?L#-]+$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^(?:[0-9*,\/-]+\s+){5}[0-9*,\/?L#-]+$/', $value)) {
echo "valid";
}java
String pattern = "^(?:[0-9*,/-]+\\s+){5}[0-9*,/?L#-]+$";
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)