Question: I am trying to filter an array based on a set of regex expression.If the item in the array matches any of the regex expression,I want o push it to a different array.I read that I can use match() and test() to do this but I'm unable to underetand how to do so.Please help.Thanks in advance.

Here are my regex exp:

```
RAM-HEXA-*F-Q1
RAM-D-AT44-*-Q2
RAM-D-AT44-*-Q3

```

My test Arr:

```
testData={
[
        { value: 'RAM-HEXA-34F-Q1
' },
        { value: 'RAM-D-AT44-AQ-Q2
' },
        { value: 'RAM-D-AT44-ZS-Q3
' },
        { value: 'RAM-D-N7-9-Q3
' },
       { value: 'RAM-QUATRA-1F-Q1
' },
        { value: 'RAM-X-AT44-T-Q2
' }
      ]
}

```

SO basically I am trying to get the items from testData that match the reg expresions. So I am trying to get a resulting array that looks like this:

```
filteredData={
[
        { value: 'RAM-HEXA-34F-Q1
' },
        { value: 'RAM-D-AT44-AQ-Q2
' },
        { value: 'RAM-D-AT44-ZS-Q3
' }]

```

Answer: 
What I believe you're looking to do is get the `jaccard_similarity` for each list in `list1`. If so, just loop through them. Also, made small corrections to the lines in `jaccard_similarity`.

```
list1=[
    ['Search','engines','using','machine','learning','pattern','detections'], 
    ['machine','learning','helped','Google','automatically','sift','pages']
]
list2 = ['Machine','learning','ever','evolving','technology']

def jaccard_similarity(list1, list2):
    intersection = len(set(list1).intersection(list2)) #no need to call list here
    union = len(list1 + list2) - intersection #you only need to call len once here
    return intersection / union #also no need to cast to float as this will be done for you

for l in list1:
    print(jaccard_similarity(l, list2))

```

Or in a comprehension

```
similarities = [jaccard_similarity(l, list2) for l in list1]

```

**Edit** Here's a much simpler way to get the `jaccard_similarity` btw:

```
def jaccard_similarity(list1, list2):
    s1, s2 = set(list1), set(list2)
    return len(s1 & s2) / len(s1 | s2)

```
You could compute the Jaccard Index between two lists using your function:

```py
jaccard_similarity(list1[0], list2)

```

returns:

```sh
['learning']
Out[7]: 0.09090909090909091

```

You could also use a loop to apply your function to the different sublists in list1 and get the Jaccard Index between the sublists of list1 and list2.