Regex validator incorrectly failing


I’m trying to find out if anyone can help me with this issue I’m unable to debug.

I’m using a “yii\validators\RegularExpressionValidator” , or ‘match’ core validator to test against UK phone numbers and postcodes. For whatever reason, the rules that I’m using, keep failing. The same rules with the same data, pass when I test them on regex101.

I’ve confirmed that the data is correct, I thought perhaps it was an issue with serializing as this is being done via an Ajax request. I’ve checked for any white-space, I’ve trimmed out the data before validating just in-case.

This is the regex I’m running for phone validation: ^(?:(?:(?(?:0(?:0|11))?[\s-]?(?|+)44)?[\s-]?(?:(?0)?[\s-]?)?)|(?:(?0))(?:(?:\d{5})?[\s-]?\d{4,5})|(?:\d{4})?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3}))|(?:\d{3})?[\s-]?\d{3}[\s-]?\d{3,4})|(?:\d{2})?[\s-]?\d{4}[\s-]?\d{4}))(?:[\s-]?(?:x|ext.?|#)\d{3,4})?$

I’ve also created the object myself in the action the form submits to, setting properties that conforms with the rules and yet they still fail validation. I think perhaps I’m missing something vital here, but I’m unable to find anything to help my situation via docs or forums.

God damn it, realized I wasn’t using delimiters in the regex syntax - doh.