Fix pattern for RegExp matching

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