Hi, this is likely a simple issue that I just can't wrap my brain around. I'm trying to extract each occurrence of a particular pattern from a string. I have tried so many variations that I don't know anymore if I'm even close, was close or am getting farther away.
Anyway, I am doing something like this: <----------- snip ------------> line='<li><h3>APAR is sysrouted TO one or more of the following:</h3> <p> <a href="http://www-01.ibm.com/support/docview.wss?uid=isg1IV06197">IV06197</a> <a href="http://www-01.ibm.com/support/docview.wss?uid=isg1IV09133">IV09133</a> <a href="http://www-01.ibm.com/support/docview.wss?uid=isg1IV10172">IV10172</a> <a href="http://www-01.ibm.com/support/docview.wss?uid=isg1IV10484">IV10484</a> <a href="http://www-01.ibm.com/support/docview.wss?uid=isg1IV10656">IV10656</a> <a href="http://www-01.ibm.com/support/docview.wss?uid=isg1IV11460">IV11460</a></p> </li>' regx_a="(\bI[V|Z]\d+)" typeset -a A for stuff in ${line} do if [[ ${stuff} =~ $regx_a ]] then A+=( ${.sh.match[0]} ) fi done print ${A[@]} <------------snip --------------> but I want to do something like this: typeset -a A=( {if [[ $stuff =~ $regx_a ]] && print ${.sh.match[@]}; } ) more to the point, is there a way to get .sh.match populated in one sweep of $line and essentially end up with: .sh.match= ( "IV06197" "IV09133" "IV10172" "IV10484" …) I'd thought about something like: if [[ $line == ~(P)/$regx_a/g ]] … thinking that a perl like regex with a "global" modifier would get all the matching substrings in the string. Also, is there a definitive discussion (perhaps in the mailing list before I joined, but haven't found with google) on the various regex functionality/features between "shell pattern matching" "ere" (like from the manpage "=~ (E)ere" and ( P ), etc.? I'm fairly new to discovering ksh's =~ operator and would like to replace a lot of the old silly awk & grep command pipes. -josh _______________________________________________ ast-users mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-users
