With the zsh shell, where {1..23} comes from and in whose patterns [A-Z] actually matches on ABCDEFGHIJKLMNOPQRSTUVWXYZ only, you could do:
$ set -o extendedglob
$ d=1/2/3/4/5/6/FOO7FOO,BARblah_BLAH_blah/8/9/10/11
$ print -rl -- ${${${d:h7:t}/[A-Z,0-9]##}/_}{1..3}
blahBLAH_blah1
blahBLAH_blah2
blahBLAH_blah3
${d:h7:t} takes the tail of the first 7 head components of the path in $d, so here FOO,BARblah_BLAH_blah, ${var:h} and ${var:t} are from csh from the late 70s, zsh extends it with ${var:h<number>} and ${var:t<number>}.
${param/pattern} like in ksh93 (from 1993 obviously) removes the first match of pattern from the parameter.
[A-Z,0-9] matches on characters from A to Z, , or characters from 0 to 9, but contrary to may other shell globs or regexp operators, that's based on codepoint rather than locale collation order, and matches on characters only, so only the 26 ASCII uppercase digits and 10 ASCII digits, not the hundreds of other characters that other engines match.
## is zsh extendedglob equivalent to the Extended Regular Expression + operator or the \+ that some regexp engine support in Basic Regular Expressions as a non-standard extension.
{1..3} extends csh's {a,b} where that's equivalent to {1,2,3} here.
print -rl prints its arguments raw on separate lines.
Some notes about your:
HAP="$(echo ${d} | cut -f 7 -d '/' | sed 's/[A-Z,0-9]\+//' | sed 's/_//')"
- best to avoid all-uppercase variable name for anything but environment variables or very wide scope variables.
echo can't be used for arbitrary data. Use print -r -- in Korn-like shells or printf posixly.
- Leaving that
${d} unquoted invokes split+glob which likely doesn't make sense here.
cut (and sed) is a text utility, it works on one line at a time, and a file path can be made of any number of lines and doesn't have to be text, so in general, you can't extract path components with it (same applies to the sed commands which would do one substitution on each line of the file path).
- as already hinted above,
[A-Z,0-9] also matches on commas which may not be what you intended.
- As already noted,
\+ is a non-standard operator. The standard BRE equivalent is \{1,\}. Or you can use the -E option of sed for ERE and then use + which is standard.
About:
for hap in [1:2]; do printf "%s\n" $HAP${hap}; done
[1:2] is a glob wildcard pattern that matches on either 1, :, or 2. Here it will trigger globbing so that [1:2] will be expanded to the list of matching files in the current working directory (sorted lexically). If there's no match (if there's no file called 1, 2 or :), in bash depending on the settings of the failglob and nullglob option, it will either cause an error or expand to nothing or be left as [1:2]. In your case the latter as I suppose neither failglob nor nullglob were set.
Again, those unquoted ${HAP}${hap} don't make any sense but kudos for using printf instead of echo.
However with printf, you could have just done:
printf '%s\n' "$HAP"{1..2}
(or printf '%s\n' "$HAP"{1,2}, bash now supports both csh's {1,2} and zsh's {1..2}).