I think there is much easier way of doing this.
Why not use Rootexplorer? just open /system/usr/keyboard-config/keyprint.xml and instead of qwerty you can write the layout file's name that suites your keyboard and save. that's it, no regex..no other stuff. just open file change text and save.
But not all ROMs have keyboard-config dir, some devs thinks that all people in the world have the same layout so they deletes that folder.
If you are one of those who got rom without it and you need to change layout - just take that folder from rom that has that folder (the one which worked for you) put it in system\usr give good permissions (folders have to have the same perm as other folders in that dir. Files have to have the same perms as other files in usr dir. and it will work after reboot.
Huawei U8800 CM7 with good old 2.6.32 kernel.
HTC Evo 3D