Question: I have a pandas dataframe `A` with column `keywords` as :-

```
 keywords
 ['loans','mercedez','bugatti','a4']
 ['trump','usa','election','president']
 ['galaxy','7s','canon','macbook']
 ['beiber','spiderman','marvels','ironmen']
 .........................................
 .........................................
 .........................................

```

I also have another pandas dataframe `B` with column `category` and `words` which is comma seperated string as:-

```
category              words
audi                  audi a4,audi a6
bugatti               bugatti veyron, bugatti chiron
mercedez              mercedez s-class, mercedez e-class
dslr                  canon, nikon
apple                 iphone 7s,iphone 6s,iphone 5
finance               sales,loans,sales price
politics              donald trump, election, votes
entertainment         spiderman,captain america, ironmen
music                 justin beiber, rihana,drake
........              ..............
.........             .........

```

All I want to map `dataframe A` column `keywords` with `dataframe B` column `words` and assign a corresponding `category`. Mapping of `keywords` column should be with each word in string of column `word`. For example:- keyword `a4` should be matched with both words in string `audi a4` in column `words`.Expected result would be:-

```
  keywords                                       matched_category
  ['loans','mercedez','bugatti','a4']            ['finance','mercedez','mercedez','bugatti','bugatti','audi']                                    
  ['trump','usa','election','president']         ['politics','politics']                                           
  ['galaxy','7s','canon','macbook']              ['apple','dslr']
  ['beiber','spiderman','marvels','ironmen']     ['music','entertaiment','entertainment','entertainment']

```

Answer: 
You can use the pattern:

```
(?<=name=).*?(?=name=)name=([a-zA-Z]+)

```

```js
var myString = "name=joe&company_id=7&name=Barbie"
var myRegexp = /(?<=name=).*?(?=name=)name=([a-zA-Z]+)/g;
var match = myRegexp.exec(myString);
console.log(match[1]); 
```
If your code targets modern version of the browsers, there is no reason to use regex. Use [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams):

```
let searchParams = new URLSearchParams("name=joe&company_id=7&name=Barbie");
var name = searchParams.getAll("name").slice(-1)[0];

```

Getting the nth instance is as easy as accessing the array returned by `getAll`

If you have the full URL at earlier point in the code:

```
let searchParams = new URL(url).searchParams;

```