regex help [Answered]
So I made a regex with little help of copilot, it looks like this:
It should match strings like this: "n,n > n,n x n,n" or like this: "n,n > n,n", where n is number between 0 and 7 (spaces between are optional)
However when I test it here https://regex101.com/r/MMnQql/1 I get no matches
The question is why? Can somebody help me?
regex101
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
9 Replies
I would recommend you make a unit test
and then post the unit test here
this kind of topic lends itself to test-driven-development (TDD)
You don't have any notion of <, > or x in your regex.
I am currently making a refactoring in my project and i have a lot of errors so i cant run my tests now
Dialect issue? Does that site support .NET flavor regex?
oh, yes it does. If it's turned on
^(?<source>[0-7],[0-7])\s?>\s?(?<destination>[0-7],[0-7])\s?(?:x\s?(?<capture>[0-7],[0-7]))?$
Feels like it has been added relatively recently.
oh thanks! totally forgot about that!
You're welcome
this can be closed i assume
✅ This post has been marked as answered!