I’m relatively inexperienced with regex but I’ve always been able to solve my issues with some googling. But I’m stumped by the code I’d need for the situation I’m currently facing.
I have a string of values with a pipe delimiter. We’ve recently added two variables to the end of the string for capture going forward, so the string will either have 6 or 8 values.
Example strings with junk values:
- unknown|yes|no|true|false|maybe
- unknown|yes|no|true|false|maybe|optional|optional
The regex I’ve written so far is: ^(.)|(.)|(.)|(.)|(.)|(.)|(.)|(.)
It captures perfectly if all 8 values are there, but doesn’t cover the 6-value string. I just can’t quite figure out the “or” statements needed to account for this. Any help would be appreciated.
ally is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.