I want a strange one.
There is a very large array of strings. All these lines fit well under a certain set of templates.
"Red Hat Enterprise Linux Server release 6.0 (Santiago)", "Microsoft Windows [Version 6.1.7601]", "HP-UX bi2 B.11.31 U ia64 3768995465 unlimited-user license", "Microsoft Windows [Version 6.3.9600]", "SUSE Linux Enterprise Server 11 (x86_64)", "Red Hat Enterprise Linux Server release 5.5 (Tikanga)", "HP-UX cfb B.11.31 U ia64 3919763569 unlimited-user license", "Microsoft Windows [Version 6.1.7601]", "SUSE Linux Enterprise Server 11 (x86_64)", "Microsoft Windows [Version 6.1.7601]", "SUSE Linux Enterprise Server 11 (x86_64)", "HP-UX mappn B.11.31 U ia64 1709713642 unlimited-user license", "HP-UX appn B.11.31 U ia64 1709713642 unlimited-user license", "SUSE Linux Enterprise Server 11 (x86_64)", "Microsoft Windows [Version 6.3.9600]", ..... That is, for example, Red Hat is described by such a pattern (for example, printf)
$vendor = "Red Hat Enterprise Linux Server"; $version = 6; $patchLevel = 0; $versionName = "Santiago"; printf("%s release %d.%d (%s)", $vendor, $version, $patchLevel, $versionName); Red Hat Enterprise Linux Server release 6.0 (Santiago)
So, I want a sort of printf on the contrary, to break a line into parts from a template.
It is clear that this is easily done with the help of regulars, but the list is really very large and, in general, will pull quite a lot of strapping to analyze the result.
Any thoughts where to look?
sscanffunction. Otherwise, you can get stuck and write a parser on the state machines, the parser lol! If the pattern is exactly simple and well-known, then the regulars here are the most. I see no reason to refuse them. - Lexx918