Home > front end >  Building a regex expression in R
Building a regex expression in R

Time:11-12

I've been trying to build an regex expression in R and while I've found some online regex builder, I can't seem to find a one that would let me enter my strings and then generate the expression that would match these strings. These online tools only seem to allow to test for expressions if you already have an idea of how they should look like, which I don't.

I have the following strings and I need a regex expression that captures only these strings and none else:

WaterFlow[1,2]
WaterFlow[1,3]
WaterFlow[1,4]
WaterFlow[2,3]
WaterFlow[2,4]
WaterFlow[3,4]

I am working in R. Any help would be appreciated!

CodePudding user response:

Here's a regex that will do it:

WaterFlow(?!\[2,[12]\]|\[3,[123]\]|\[1,1\])\[[123],[234]\]
  • Related