Ladies & Gents
Thanks for all the great help and guidance you offer.
I need to test 550 unique strings for the presence of special characters in them and preform actions based on which pattern is detected.
Those five patterns are;
#- as in the sample string et0106.htm#9-22 (400 of these ?)
#-# as in the sample string et0101.htm#1-et0102.htm#3 (100 of these?)
#-#-# as in the sample string et0119.htm#21-et0120.htm#-et0121.htm#4
; as in the sample string et1027.htm#6-et1028.htm#13;et1029.htm#22-23
and a fall through et0534.htm# (there is only this one)
This does not work
Code:
for ALIYAH in "${arr[@]:1:11}";do
pat=[#-]
if [[ "$ALIYAH" == "$pat" ]]; then
SHIR1="$(echo "$ALIYAH" |awk -F \# '{print $1}')"
START1="$(echo "$ALIYAH" |awk -F \# '{print $2}'|awk -F - '{print $1}')"
END1="$(echo "$ALIYAH" |awk -F - '{print $2}')"
pat2=[#-#]
elif [[ "$ALIYAH" == "$pat2" ]]; then
# some actions
pat3=[#-#-#]
elif [[ "$ALIYAH" == "$pat3" ]]; then
# some action
pat4=[;]
elif [[ "$ALIYAH" == "$pat4" ]]; then
# some actions
else
SHIR10="$(echo "$ALIYAH" |awk -F \# '{print $1}')"
fi
It falls right out the bottom to the fall through "else". Some of the debug
Code:
+ for ALIYAH in '"${arr[@]:2:11}"'
+ pat='[#-]'
+ [[ some.htm#11-38 == \[\#\-\] ]]
++ echo some.htm#11-38
++ awk -F '#' '{print $1}'
+ SHIR10=some.htm
The pattern of the special characters is the only constant in the strings but the number of [a-z][0-9] between them changes as can be seen from the samples above. So clearly something more complex than what I have is required to make it ignore the regular characters between the special characters.
To break the most complex one down
et1027.htm # 6 - et1028.htm # 13 ; et1029.htm # 22 - 23
filename # regex in file - filename # regex in file ; filename # regex in file - regex in file
The file names can be one character longer but never shorter
The regex can be as many as 3 numbers long (123)
Trying to change the special characters to something else is somewhat problematic because of the difference in the strings. I already had to generate them by hand, I don't want to go through and change them by hand too.
Thanks Again