Abin Manathoor Devasia
Abin Manathoor Devasia

Reputation: 1973

RegExp for File URL

I write a RegExp for validate a file URL

file:/{2,3}[a-zA-Z0-9]*\\|?/.*

for URL like

file:/D:/workspace/project/build/libs/myjar-1.0.jar

But doesnt work, am looking for a pattern that matches only URL like this,no other.

Pattern Will return false URLs like

file:/workspace/project/build/libs/myjar-1.0.jar and file:/D:/workspace/project/build/libs/myjar-1.0 are will not match

please help

Upvotes: 0

Views: 93

Answers (2)

brandonscript
brandonscript

Reputation: 72875

Complete question rewrite

Given the OP's updated criteria, the regex you're looking for is file\:\/\w\:\/[^\s]*\.jar; ensure you enabled g (global) and i (case-insensitive) modifiers.

See a working example on Regex101

Upvotes: 1

Jorge Campos
Jorge Campos

Reputation: 23361

If there is no context or rule your regex should be:

/file\:.*/i

See it here: http://regex101.com/r/yY5xG6

Upvotes: 0

Related Questions