updated regex expressions

This commit is contained in:
张壹 2018-11-14 15:23:49 -08:00
parent 77c2ebdef4
commit b140889c61

View File

@ -157,7 +157,7 @@ if [[ ${_title} != 'Null' ]]; then
while read _oneline
do
#first get all hyper links, including websites, images and files. save them to a single string separated by whitespace
_link_string=${_link_string}`echo "${_oneline}" | grep -Eo "!?\[[a-zA-Z0-9 \-\_]*\]\([a-zA-Z0-9\\\./: \-\_]*\)"`" "
_link_string=${_link_string}`echo "${_oneline}" | grep -Eo "!?\[[a-zA-Z0-9 .-_]*\]\([a-zA-Z0-9_:/.-]*\)"`" "
echo "${_oneline}" >> ${_tmpfile}
done < ${_mfile}
else
@ -177,7 +177,7 @@ else
_outfile_end=${_oneline:2}
else
#first get all hyper links, including websites, images and files. save them to a single string separated by whitespace
_link_string=${_link_string}`echo "${_oneline}" | grep -Eo "!?\[[a-zA-Z0-9 \-\_]*\]\([a-zA-Z0-9\\\./: \-\_]*\)"`" "
_link_string=${_link_string}`echo "${_oneline}" | grep -Eo "!?\[[a-zA-Z0-9 .-_]*\]\([a-zA-Z0-9_:/.-]*\)"`" "
echo "${_oneline}" >> ${_tmpfile}
fi
done < ${_mfile}
@ -207,23 +207,32 @@ fi
#combine output filename
_outfile=${_outfile}${_outfile_end}.md
#echo ${_link_string}
#get link names from _link_string and save a string
_link_names_string=`echo ${_link_string} | grep -Eo "\[[a-zA-Z0-9 \-\_]*\]"`
_link_names_string=`echo ${_link_string} | grep -Eo "\[[a-zA-Z0-9 .-_]*\]"`
#change whitespace in every link name into -
_link_names_string=${_link_names_string//" "/"-"}
#delete symbols \[ and \] in link names
_link_names_string=${_link_names_string//[\[|\]]/''}
_link_names_string=${_link_names_string//'.'/'-'}
#convert _link_names_string to an array
_link_names=(${_link_names_string})
#for i in ${_link_names[@]}; do
# echo ${i}
#done
#get link addresses from _link_string and save a string
_link_addresses_string=`echo ${_link_string} | grep -Eo "\([a-zA-Z0-9\\\./: \-\_]*\)"`
_link_addresses_string=`echo ${_link_string} | grep -Eo "\([a-zA-Z0-9_:/.-]*\)"`
echo ${_link_addresses_string}
#change whitespace in every link address into -
_link_addresses_string=${_link_addresses_string//" "/"-"}
#delete symbols \( and \) in link names
_link_addresses_string=${_link_addresses_string//[\(|\)]/''}
#convert _link_addresses_string to an array
_link_addresses=(${_link_addresses_string})
#for i in ${_link_addresses[@]}; do
# echo ${i}
#done
#exclude http[s] links to get _copy_names and _copy_addresses
#we use year-month to sort files by month
@ -304,4 +313,4 @@ fi
#check if the output file should be saved
if [[ ${_savefile} == 0 ]]; then
rm ${_outfile}
fi
fi