Question: I have two values (k and j) which I know are within an nx3 matrix (M). I know that they're and on the same row and that j is always to the right of k, so if k is in M(2,1), then j will be in M(2,2). I tested for this earlier in the function, but now I want to know which row that is for a given k and j. I need the row number of their location to proceed. There are no duplicate combinations of k and j in the matrix.

So if I have the matrix

M= 

```
1 4 5
1 5 7
k j 5
4 5 6
2 3 1

```

Then I want to know that they're in row 3. None of the columns are ordered. 

**What I have tried**:

I used the code below

```
[row,~] = find(M==k);

```

I'm not sure how to look for a combination of them. I want to avoid using the find function. I hope to potentially use logical indexing.

How do I go about doing this? I hope this question makes sense.

Answer: 
You may use matching approach with `(?:[^,\\]+|\\.)+`:

```
match(/(?:[^,\\]+|\\.)+/g)

```

See the [regex demo](https://regex101.com/r/iP9cM5/1)

**Details**: the `(?:[^,\\]+|\\.)+` matches 1 or more occurrences (`(?:...)+`) of a 1+ characters other than `,` and `\` (with `[^,\\]+`) or (`|`) any escaped sequence (`\\.`)

```js
var s = "http://some.com/\\,brabra,400,500"
console.log(s.match(/(?:[^,\\]+|\\.)+/g));
```

Or a workaround if the comma to be split with is always followed with a digit:

```
split(/,(?=\d)/)

```

See [this regex demo](https://regex101.com/r/tG5vE6/1)

```js
var s = "http://some.com/\\,brabra,400,500"
console.log(s.split(/,(?=\d)/));
```
A classic, if slightly inelegant approach for such problems is to replace some characters with a magic token, then put them back later:

```
str
  .replace("\\,", "DONT_SPLIT_HERE")
  .split(',')
  .map(part => part.replace("DONT_SPLIT_HERE", "\\,")

```