Newbie Regex confusion

David V Glasgow dvglasgow at gmail.com
Wed Aug 1 12:34:04 EDT 2018


I am just dipping my toes in the shallows of regex, and have already stubbed my toe on a rock.  Well two, actually.

I am looking to identify the lines of a field (that contain lots of words and symbols with no particular structure or separator ) finding age related terms, which can be in a variety of forms.  I made a list of the terms that I want to use.

First problem:

I use the following filter line

filter lines of it with regex pattern i

… where i is a keyword lifted from my list.  Oddly, where i is just ordinary characters, it works fine.  However if it includes a wildcard symbol, it chokes with “execution error at line 9 (matchChunk: error in pattern expression), char 1”.  For example, if i = child* (intending to match child, childlike, childhood, childish etc).  I know that’s a bad example, because just ‘child' will do the trick.  However, there seems to be some voodoo needed to put a regex expression into a variable, is that right?

Second problem is the sheer brain ache from trying to work out how to efficiently  match lines containing 8 yo, 8 yr, 8yr, 8yo, 8 year and 8year, but not 18 year, 38yo etc etc.

The simplest way would be to include all variants in the keyword list.  However, that means more sweeps through the repeat loop.  And it wouldn’t solve the problem of excluding  18 yo, 28 yo matching, unless I can construct a regex expression which will test the absence of any number between 1 and 9 immediately before the actual string I am finding.  

Am I on a wild goose chase here?  




Best Wishes,
David Glasgow


 <http://www.i-psych.co.uk/> <https://twitter.com/iPsychApps>

 <https://twitter.com/iPsychApps> <http://uk.linkedin.com/in/davidvglasgow>
 <http://uk.linkedin.com/in/davidvglasgow>



More information about the use-livecode mailing list