I'm trying to convert projects from other environments and use regex for a fair number of projects to parse for text items between 2 patterns.
However i can't seem to get this working in LC
Example text to search (a tiny fragment of a huge text file - in this example i want to extract the 'Global' values):
Code: Select all
Timing Information
==========================================================
Clip Duration;960.531;ms
Average RR Duration;960.531;ms
Enddiastolic frame time;8599.53;ms
Endsystolic frame time;7996.41;ms
Reference time;7661.34;ms
Trigger time;7661.34;ms
Results
==========================================================
Global
----------------------------------------------------------
EDV;124.35;ml
EDVi;--.--;
ESV;51.52;ml
ESVi;--.--;
SV;72.83;ml
EF;58.57;%
Mass;101.43;g
SDI;5.47;%
GLS;-19.01;%
GCS;-28.13;%
Twist;8.87;°
Torsion;0.94;°/cm
ED;8599.53;ms
ES;7994.17;ms
SDII;2.20;%
Results
==========================================================
Strain
Principal tangential
T2P
Minimum
----------------------------------------------------------
Ase15Model16SegmentZoning Segment 0 [ average];346.24;ms
----------------------------------------------------------
Ase15Model16SegmentZoning Segment 1 [ ant];330.60;ms
Ase15Model16SegmentZoning Segment 2 [ant/sept];337.30;ms
Ase15Model16SegmentZoning Segment 3 [inf/sept];509.31;ms
Ase15Model16SegmentZoning Segment 4 [ inf];402.08;ms
Ase15Model16SegmentZoning Segment 5 [ inf/lat];368.58;ms
Ase15Model16SegmentZoning Segment 6 [ ant/lat];359.64;ms
----------------------------------------------------------
Ase15Model16SegmentZoning Segment 7 [ ant];337.30;ms
Ase15Model16SegmentZoning Segment 8 [ant/sept];397.62;ms
Ase15Model16SegmentZoning Segment 9 [inf/sept];489.20;ms
Ase15Model16SegmentZoning Segment 10 [ inf];502.60;ms
Ase15Model16SegmentZoning Segment 11 [ inf/lat];352.94;ms
Ase15Model16SegmentZoning Segment 12 [ ant/lat];348.47;ms
----------------------------------------------------------
Ase15Model16SegmentZoning Segment 13 [ ant];357.41;ms
Ase15Model16SegmentZoning Segment 14 [ sept];366.34;ms
Ase15Model16SegmentZoning Segment 15 [ inf];332.84;ms
Ase15Model16SegmentZoning Segment 16 [ lat];348.47;ms
----------------------------------------------------------
The regex below works in all other environments i use:
Code: Select all
(?msi)(?<=Global\n----------------------------------------------------------\n).*?(?=\n\n\nResult)
Code: Select all
EDV;124.35;ml
EDVi;--.--;
ESV;51.52;ml
ESVi;--.--;
SV;72.83;ml
EF;58.57;%
Mass;101.43;g
SDI;5.47;%
GLS;-19.01;%
GCS;-28.13;%
Twist;8.87;°
Torsion;0.94;°/cm
ED;8599.53;ms
ES;7994.17;ms
SDII;2.20;%
Code: Select all
Local tQuery
put "(?msi)(?<=Global\n----------------------------------------------------------\n).*?(?=\n\n\nResult)" into tQuery
filter field "the field containing all text" with regex pattern tQuery into field "the field to showing the result"
Grateful for help with this...
Edit: I realise i'm probably 'doing it wrong' -- have tried MatchText and MatchChunk with no luck. It's also possible that regex lookarounds don't work in this context, but i don't know enough about what works with LiveCode...
I have a wordy workaround using chunk expression which works, but inelegant and many more lines of code, so ideally would go with a regex solution if that were possible... grateful for any livecode/regex gurus to chime in!