I need the below regex to select only those of total size X:
[[JN]*P?[JN]*]N
EDIT:
e.g. for 6:
- JJPNNN -> JJPNNN
- ONNJNNNO -> NNJNNN
- NPJNJNN -> NPJNJN, PJNJNN
- NPJNN -> False
I need it to capture the group.
I need the below regex to select only those of total size X:
[[JN]*P?[JN]*]N
EDIT:
e.g. for 6:
I need it to capture the group.
out
You can use lookahead to first check the length, like this:
Also, you seem to have too many brackets. To make the expression match your examples, you need to remove the outermost one:
Here is a small demo using ideone.
You can use the size limiting
something like that limits a size of 5~10
You should look up on it, there is tons of answered questions about this topic