I have this
/([^\/\|\#\<\(\>\;\s][0-9]*[\s][KB]{2})
in order to be specific i had to use [KB]{2} I get the value needed, but can I convert the final print to MB?
Exemple: match= 2000KB = 2MB?
Thanks
I have this
/([^\/\|\#\<\(\>\;\s][0-9]*[\s][KB]{2})
in order to be specific i had to use [KB]{2} I get the value needed, but can I convert the final print to MB?
Exemple: match= 2000KB = 2MB?
Thanks
Sure you can; capture the unit and the number separately like this:
/[^\/\|\#\<\(\>\;\s]([0-9]*)[\s]([KB]{2})
Assuming your original regex is correct, of course. Then:
if ($2 eq "KB" && $1 > 1024) {
$1 /= 1024;
$2 = "MB";
}
lol on the sting "2000 KK"
your regex matches
$1 = 000
$2 = KK
better try this one ;)
/(\d+)\s*(KB)/