Fix pattern for RegExp matching

Bug: RegExp pattern didn't match with /.../gi
Fix: Change "(i?g?$)" to "(|i|g|ig|gi)$"