Capturing subgroups of a text wave or string list
tweed
Say I have a wave or a string like:
String mStr = "foo24,bar,foo,foo35"
Make /O/T mWave = {"foo24","bar","foo","foo35"}
Make /O/T mWave = {"foo24","bar","foo","foo35"}
Is there any igor function to extract the *groups* from a regex, instead of just the matching elements (like Grep)? For example, with strings
String mRegex = "(foo\d)"
String capturedGroups
// the following 'magic function'would put "foo2,foo3" in capturedGroups. In other words, the actual group that matched
GetGroups /E=(mRegex) mStr,capturedGroups
I ask because my alternative is calling SplitString on each of the elements of the string list or text wave, which is prohibitively expensive and slow in my experience. Thanks!
String str
String tmp = str[0,2]
if (CmpStr(tmp,"foo") == 0)
return 1
endif
return 0
End
Function Demo()
Make /O/T mWave = {"foo24","bar","foo","foo35"}
Wave/T mWave = root:mWave
Extract /O mWave, destWave, Select(mWave)
End
June 21, 2015 at 07:30 am - Permalink