Purni
Purni

Reputation: 367

Regex expression to validate invalid url charcters

Can you help me to find Regex expression to validate invalid characters in a url string? Everything I found in the internet is having http/https validations. That shouldn't be the case. I need just a url string to validate invalid url characters(such as $,},{,-,etc..)

Upvotes: 1

Views: 631

Answers (2)

MarkWriteCodes
MarkWriteCodes

Reputation: 133

this works fine for me:

[^\w\.@-\\]

if you want to allow character simply add these into the regex...for example if you want to allow "%" become:

 [^\w\.@-\\%]

Upvotes: 2

Guilherme Borges
Guilherme Borges

Reputation: 54

(\b(https?|ftp|file)://)?[-A-Za-z0-9+&@#/%?=~|!:,.;]+[-A-Za-z0-9+&@#/%=~|]

Upvotes: 0

Related Questions