Timur Zhukov
Timur Zhukov

Reputation: 31

C++: How to find word with split? Regex

I need to find a serial number that is split with "~" characters and it may have from 10 to 30 letters in it.

Currently I am using this regex pattern: "~[A-Z]~[A-Z]~[A-Z]~[A-Z]~[A-Z]~[A-Z]~[A-Z]~[A-Z]~[A-Z]~[A-Z]".

I need to change to it, so that it would search not only 10 letters, but any count up to 30.

Upvotes: 0

Views: 73

Answers (1)

KekuSemau
KekuSemau

Reputation: 6852

(~[A-Z]){10,30}

This should match any number of repetitions from 10 to 30.
(It is greedy by default, so it will match the longest possible string.)

Upvotes: 1

Related Questions