Parsing required subsystems logic

Here’s an example of what a vaygr research item might look like:

{
	Name =					"ShipyardBUILDSPEEDUpgrade1",
	RequiredResearch =		"",
	RequiredSubSystems =	"Research | CapShipProduction & Hyperspace",
	RequireTag = 			"VaygrBuilder",  
	Cost = 					1000,
	Time = 					95,
	DisplayedName =			"$7825",
	DisplayPriority =		65,
	Description =			"$7826",
	UpgradeType =			Modifier,
	TargetType =			Ship,
	TargetName =			"Vgr_ShipYard",
	UpgradeName =			"BUILDSPEED",
	UpgradeValue =			1.3,
	Icon =					Icon_Build,
	ShortDisplayedName =	"$7240",
}

A gamerule in my mod disables certain modules, but not others. How do I parse out using a script the requirement for a module in the RequiredSubSystems field? I need to be able to do this no matter what other modules are listed in that field, no matter the order, and no matter what logical operators (& and |) are used. Has anyone attempted this in the past? I suspect it may be enough to strip the module name and the immediately-preceding operator since they are meant to be read from left to right. Is this correct? Thanks.

PS. Does the game ever use parentheses to group items together?

I discovered the standard string library is not available here, so I may be screwed.

The only thing I can think of is to add new fields to the table:

{
	Name =					"ShipyardBUILDSPEEDUpgrade1",
	RequiredResearch =		"",
	RequiredSubSystems =	"Research | CapShipProduction & Hyperspace",
	RequireTag = 			"VaygrBuilder",
	ReqSubNoRch =			"CapShipProduction & Hyperspace",
	ReqSubNoHyp =			"Research | CapShipProduction",
	ReqSubNoRchNoHyp =		"CapShipProduction",
	Cost = 					1000,
	Time = 					95,
	DisplayedName =			"$7825",
	DisplayPriority =		65,
	Description =			"$7826",
	UpgradeType =			Modifier,
	TargetType =			Ship,
	TargetName =			"Vgr_ShipYard",
	UpgradeName =			"BUILDSPEED",
	UpgradeValue =			1.3,
	Icon =					Icon_Build,
	ShortDisplayedName =	"$7240",
}

Except, I have four parameters that work like this, for a total of 16 possible combinations of states, each needing its own field. If I add another parameter then I will need 32 fields.

:frowning:

Another solution is to write external tools (written in Python for instance) that spit out all the build/research tables.