C++: Regex pattern

Clash Royale CLAN TAG#URR8PPPC++: Regex pattern
I got a regex pattern: (~[A-Z]){10,30} (Thanks to KekuSemau). And I need to edit it, so it will skip 1 letter. So it will be like down below.
Input: CABBYCRDCEBFYGGHQIPJOK
Output: A B C D E F G H I J K
[A-Z]([A-Z])?
What's with the
~? Just replace .(.) with ` $1` (space+$1). See it here at regex101.– ClasG
15 hours ago
~
.(.)
2 Answers
2
Just match two letters each iteration but only capture the second part.
(?:~[A-Z](~[A-Z])){5,15}
live: https://regex101.com/r/pIAxH8/1
I cut the repetition count (the bit inside the {}'s) by half since the new regex is matching two at a time.
The ?: in (?:...) bit disables capturing of the group.
?:
(?:...)
In regex only, there is no way you can achieve this directly.
But you can do this in code:
Use following regex:
(.(?<pick>[A-Z]))+
and in code make a loop on "captures" of desired group, like in c#:
string value = "";
for (int i = 0; i < match.Groups["pick"].Captures.Count; i++)
{
value = match.Groups["pick"].Captures[0].Value;
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Perhaps for that input you could match the first character and capture the second character in a group and replace with a whitespace and the capturing group
[A-Z]([A-Z])?– The fourth bird
17 hours ago