[1.7.x] Fixed #22255 -- Added support for specifying re flags in RegexValidator

Backport of 4d0c5f61427a8e67552ee2d777fffbadc7aff3b2 from master.