Fix pattern for RegExp matching

Bug: RegExp pattern didn't match with /.../gi
Fix: Change "(i?g?$)" to "([ig]{0,2})$"