Regular Expressions 101

Community Patterns

Absolute File Path Validation

1

Regular Expression
ECMAScript (JavaScript)

/
^([a-z]:)(((\\|\/)[a-z0-9^&'@{}\[\],$=!\-#\(\)%\.\+~_]+)*(\\|\/))([^\\\/:\*\"<>\|]+\.[a-z0-9]+)
/
ig

Description

Matches absolute file paths, such as

C:\Users\username\Documents\filename.txt The path must contain a file and extension at the end

Submitted by anonymous - 3 years ago