-4

I would like to identify the following pattern on a string (all words are separated by comma)
1. The string starts with RO,TA,PR
2. The string ends with TA,TO
3. After RO,TA,PR it can have multiples TA,PR

Example of valid patterns:
- RO,TA,PR,TA,TO
- RO,TA,PR,TA,PR,TA,TO
- RO,TA,PR,TA,PR,TA,PR,TA,TO
- RO,TA,PR,TA,PR,TA,PR,TA,PR,TA,TO
- RO,TA,PR,TA,PR,TA,PR,TA,PR,TA,TO

Example of invalid patterns:
- RO,PR,TA,TO
- RO,TA,TO,PR,TA,TO
- RO,TA,RO,TA,TO
- RO,TA,PR,TO

1 Answers1

0

you can try this: ^RO,TA,PR(,TA,PR)*,TA,TO$.

To begin with RO,TA,PR: ^RO,TA,PR

To end with ,TA,TO: ,TA,TO$

The star * repeat the regex inside () 0 or several times.