Since a specific comment-question on your other question (implicitly) denied that it was only the first an last words that you wanted to exclude, and since none of your (limited) examples show embedded bare text which is not required:
BEGIN {
FS = ""
}
{
for (CharFromStart=1;CharFromStart<=NF;CharFromStart++) {
if ( $CharFromStart ~/"|'/) {
break
}
}
for (CharFromEnd=NF;CharFromEnd>0;CharFromEnd--) {
if ( $CharFromEnd ~/"|'/) {
break
}
}
if ( CharFromStart <= CharFromEnd ) {
print ">"substr($0,CharFromStart,(CharFromEnd-CharFromStart+1))"<"
}
else {
print "Move along please, nothing to see here"
}
}
With some augmented test data:
gfdg "jkfgh" "jkfd fdgj fd-" ghjhgj
gfggf "kfdjfdgfhbg" "fhfghg" jhgj
jhfjhg "dfgdf 'ffdg' gfd" "dgffd 'fdg'"fgf
fgfdg 'dfj "jfdg" jhfgjd' 'hfgdh jfdhgd jkfghfd' hgjghj
jhfjhg "dfgdf 'ffdg' gfd" "dgffd 'fdg'" fgf
jhfjhg "dfgdf 'ffdg ' gfd" " dgffd 'fdg'"fgf
kiuj jajdj "dfgdf 'ffdg ' gfd" " dgffd 'fdg'" s fgf
dslkjflkdsj ldsk gfdkg ;kdsa;lfkdsl f ljflkdsjf l
ldsfl dsjfhkjds dshfjkhds kdskjfhdskjhf " dsflkdsjflk
' dlfkjdslfj kdsjflkdslj djlkfjdslkjf
dskfjds dshfdkjsh dshjkjfhds "
"""
Gives:
>"jkfgh" "jkfd fdgj fd-"<
>"kfdjfdgfhbg" "fhfghg"<
>"dfgdf 'ffdg' gfd" "dgffd 'fdg'"<
>'dfj "jfdg" jhfgjd' 'hfgdh jfdhgd jkfghfd'<
>"dfgdf 'ffdg' gfd" "dgffd 'fdg'"<
>"dfgdf 'ffdg ' gfd" " dgffd 'fdg'"<
>"dfgdf 'ffdg ' gfd" " dgffd 'fdg'"<
Move along please, nothing to see here
>"<
>'<
>"<
>"""<
This works by setting the FS built-in variable for the Field Separator to nothing. This causes each character on the line to be treated as an individual field.
A loop "up" the line using $variablename to find the first quote or apostrophe. A loop "down" the line to find the last quote or apostrophe.
A quick check that at least one was found, and print the substring of the line from the first quote or apostrophe to, and including, the last.
Where there is only one quote or apostrophe on the line, it will be printed, but simple to not do so.
If quote or apostrophe is "unbalanced", no problem with the extraction (unless you want to actually know). Embedded blanks, tabs or such-like will stay where they are, relative to the first quote or apostrophe.