What I would like to do is capture the info in a hash whose keys are the variable names listed above. For example lets say I parsed myVarA this is what I want to capture://File Snippet Begin// . float myVarA < float UIMin = 1; float UIMax = 0; float UIStep = .001; string UIWidget = "slider"; > = 0.5f; float myVarB = 1.0; float4 myVarC = {1,0,0,1}; . //File Snippet End//
The difficulty (at least for me anyway) is capturing the "UI" information "if" it exists. I have tried different regex fencings but am unable to capture both variables with "UI" information and variables without. The real problem is the data-types inside the "UI" description delimited by the "<" and ">" characters. I also tried simplifying things by loading the whole file into a string marking up the data-types and throwing out the whitespace as follows:$vars{myVarA}->{type} = "float" $vars{myVarA}->{value} = 0.5 $vars{myVarA}->{ui}->{min}=0 $vars{myVarA}->{ui}->{max}=1 $vars{myVarA}->{ui}->{step}=0.001 $vars{myVarA}->{ui}->{widget}="slider"
But even in this from I can't come up with a way to split off the UI description because of the data-types inside the carrots. I tried:#after dumping file to string $file_str=~ s/(float|float2|float3|float4|string)\s+/$+\#/g; $file_str =~ s/\s*//g;
as well as:$file_str=~s/\<.*(string|float|float2|float3|float4).*\>//g;
but no go... I am hoping that the enlightened here can show me the way.. :)@lines = split/(float|float2|float3|float4)\#\<.*\>=.*\;/,$file_str;
In reply to Tricky Parsing Ko'an by jmmistrot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |