Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

regex for url in bash

regex='^(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|].[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]$'

url='http://www.google.com/test/link.php'
if [[ $url =~ $regex ]]
then 
    echo "$url IS valid"
else
    echo "$url IS NOT valid"
fi
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regex #url #bash
ADD COMMENT
Topic
Name
3+1 =