Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › xlate help and pattern matching
Can anyone help me with the following issue:
I need to check if the mrn is 8 characters, and the first 4 digits are all alpha and the last 4 digits are all numeric? Can anyone help me with this, please?
Thanks.
Femina
set var ABCD1234
if {[regexp — {^w{4}d{4}$} $var]} {
echo var has 4 characters followed bt 4 digits
}
Thank you Charlie! This really helped. I was breaking this up in two parts. Also, thank you Jim K.
Charlie,
I am still not getting this to work. I have an example:
set var 12345678
This still evaluates to true. It should not pass as it does not meet the condition.
Please advise.
I think that w can match letters or numbers, so you need to do something like this:
if {[regexp — {^[A-Za-z]{4}d{4}$} $var]} {
My bad, David is correct w will match all alphanumerics. Sorry about that.
Next time I guess I need to test it better 😀
That worked – thanks guys!