I am attempting to use regular expression substitution for the following types of strings:
'y = 0'
'y = 10'
'y = 23'
I want the replacement to return the number only if it lies between 1 and 22. (i.e. less than 1 and greater than 22 will return some other result)
I have it written as follows, and I cannot understand why this won't work:
regexprep('y = 5', 'y = '\b([19]$1[09]2[02])\b', '$1')
Is there something I am missing about syntax here? I find that if I remove the \b I can get the proper result for:
regexprep('y = 0', 'y = ([19]1[09]2[02])', '$1')
i.e. no change, and for the numbers from 122 I get the right result, but then all numbers greater than 22 are also getting replaced by $1 as well. I have no idea why. Any help would be great. Thanks.
