Given an array of strings,
array1 = ["abcdwillbegoneabcccc","cdefwilbegokkkabcdc"]
and another array of strings which consist of patterns e.g. ["abcd","beg[o|p]n","bcc","cdef","h*gxwy"]
the task is to remove substrings that match any of the pattern strings. for example a sample output for this case should be:
["willbegonea","wilbegokkk"]
because we have removed the substrings (prematch or postmatch as is appropriate depending on the position of occurrence) that matched one of the patterns. Assume that the one or two matches will always occur at the beginning or towards the end of each string in array1.
Any ideas of an elegant solution to the above in ruby?