You must have come accross some of my older posts as I haven't been hugely active lately. But yes, I am RegExp fan.Originally Posted by xld
Yep, RegExp is fantastic when parsing/seraching a particular pattermOriginally Posted by xld
When the rules have a number of exceptions or checks then its a choice of using multiple RegExps and/or doing "pre or post processing" as you did above.
For example, when I wrote code to change cell references from absolute to relative or vice versa, the patten I used for the cell address was
(\$?)([A-Z]{1,2})(\$?)(\d{1,5})
The code then has a step to check that any five digit number is less than 65537, and that the next character is not numeric, ie that the numeric portion is a valid cell reference
A longer pattern could have done the job with the RegExp alone, with an additional check that the next character neccesitates a word break
(\$?)([A-Z]{1,2})(\$?)(\d{1,4}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d{1}|6553[0-6])\b
But I figured it was more transparent to work with a shorter pattern and then post process in the code.
When I've parsed street addresses I've had to do similar pre-work to catch the "inconsistencies" in how the data may be presented.
So its a choice between RegEx world and "normal" coding, ie in your code below you could use a RegExp Replace to change your case from lower to upper case rather than Ucase.
One of VBscripts problems is that is doesn't have the lookahead or lookbehind capability of RegExp, this adds to the prework needed.
Anyhow ......... is there more info on your sort program?
I'll have a crack at this with as much RegExp as possible but I don' tthink it will be pretty.
Cheers
Dave




Reply With Quote