I am trying to write an alias to extract a string of 8 hex characters. I have tried some various combinations, not of which seem to work. Eventually I came up with this string:
if $regex(hex_code, $$1, /([0-9a-fA-F]{8})/) { return $regml(hex_code,1) }
But the following examples did not give the results I expected:
alias testprce {
;var %localstring = $regex(hex_code, $$1, /(\d{3})/)
;var %localstring = $regex(hex_code, $$1, /([:xdigit:]{3})/)
;var %localstring = $regex($$1, /[:xdigit:]/)
echo 14 %AllUsers_CustomWindow (Reg Ex test): $$1, %localstring $regml(hex_code,1)
}
test command used was:
/testprce ~d829879a I have had some interesting results; but not what I expected.
The first results in "1". I find this surprising, because I thought that it would result in "4" (829, 298, 987, 879).
The 2nd and 3rd examples result in "0" as well.
I have tried reading the PRCE guide (extracted manual entry), but I think I am confusing myself somewhere down the line.
This is my first real foray into regex, I have done a quick search of the forum here, but the examples I came up with were too complicated for me (at this stage).
Can someone please explain the (strange to me) results?
Thanks,
DK