Test, validate and match regular expressions
Matches and parses patent classification codes (IPC, CPC, and Japanese FI) by capturing each hierarchical part into named groups: section (letter A-H or Y), class (2 digits), subclass (letter), group number, subgroup after a slash, and an optional trailing FI subsubgroup letter. It uses Python conditional patterns ((?(group)...)) so each segment only matches if the preceding one did, allowing it to match both full codes like 'H01L 21/02 B' or 'Y02E 10/50' and partial codes like 'A61K'. Useful for extracting and tokenizing patent classification symbols from documents.