Created
October 4, 2023 07:49
-
-
Save guitarrapc/52439239e19634c9e54fa243158ace60 to your computer and use it in GitHub Desktop.
Regex match example with some Unity Headless log.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var messages = new[] { | |
"Invalid VFX Particle System. It is skipped.", | |
"WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?", | |
"WARNING: Shader Did you use #pragma only_renderers and omit this platform?", | |
"ERROR: Shader Sniper/InvisibleShadowCasterUniversalRP shader is not supported on this GPU (none of subshaders/fallbacks are suitable)", | |
"ERROR: Shader Hidden/Universal Render Pipeline/Foobar shader is not supported on this GPU (none of subshaders/fallbacks are suitable)", | |
"WARNING: Shader Unsupported: 'SineVFX/FooEffects/SG/DissolveParticleFlip' - All subshaders removed", | |
}; | |
var regexes = new[] { | |
new Regex("^Invalid\\s+VFX\\s+Particle\\s+System\\.", RegexOptions.Compiled), | |
new Regex("^\\w+:\\s+Shader\\s+.*", RegexOptions.Compiled), | |
}; | |
foreach (var message in messages) | |
{ | |
var matched = false; | |
foreach (var regex in regexes) | |
{ | |
matched = regex.IsMatch(message); | |
if (matched) | |
{ | |
$"MATCHED: {message} <- `{regex.ToString()}`".Dump(); | |
break; | |
} | |
} | |
if (!matched) | |
{ | |
$"FAILED: {message}".Dump(); | |
} | |
} | |
} | |
// MATCHED: Invalid VFX Particle System. It is skipped. <- `^Invalid\s+VFX\s+Particle\s+System\.` | |
// MATCHED: WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off? <- `^\w+:\s+Shader\s+.*` | |
// MATCHED: WARNING: Shader Did you use #pragma only_renderers and omit this platform? <- `^\w+:\s+Shader\s+.*` | |
// MATCHED: ERROR: Shader Sniper/InvisibleShadowCasterUniversalRP shader is not supported on this GPU (none of subshaders/fallbacks are suitable) <- `^\w+:\s+Shader\s+.*` | |
// MATCHED: ERROR: Shader Hidden/Universal Render Pipeline/Foobar shader is not supported on this GPU (none of subshaders/fallbacks are suitable) <- `^\w+:\s+Shader\s+.*` | |
// MATCHED: WARNING: Shader Unsupported: 'SineVFX/FooEffects/SG/DissolveParticleFlip' - All subshaders removed <- `^\w+:\s+Shader\s+.*` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment