regex problem unresolved

Dear Gurus, I was suggested by experts to post runnable codes to seek advice. Unfortunately, after 4-day trial, I'm unable to break down the large codes written by others to a smaller one. And as what xhoster inferred exactly, the matching string comes from a data file and therefore cannot be known in