Jump to content

Featured Replies

Posted

I have a database field which accepts FontAwesome icon classes. It's a text field with the following regex:

^(fa(-[0-9a-zA-Z]+)+)( (fa(-[0-9a-zA-Z]+)+)+)*$

Plugging this regex string into regexr, it properly validates my chosen FontAwesome declaration:

fa-solid fa-balance-scale-right fa-4x

If the regexr link dies, the only custom setting is that I've configured it to be PCRE validation.

However, when attempting to create a new record, it fails the regex operation. What is causing this validation to fail?

Could contain: Page, Text, Electronics, Hardware

Could contain: Text, Nature, Night, Outdoors, File

Edited by Foxtrek_64
Add details about regexr config

Solved by Ryan Ashbrook

Go to solution

PHP 7.4+ uses PCRE2 validation. Have you tried scaling back the value which you are inserting? Does the validation work with just "fa-solid"?

  • Author
3 minutes ago, Jim M said:

PHP 7.4+ uses PCRE2 validation. Have you tried scaling back the value which you are inserting? Does the validation work with just "fa-solid"?

I've tried with just fa-solid. It does not pass validation.

Please be advised I have tagged a developer to this topic for further review.

  • Solution

You are missing your beginning and end delimiters. Try this:

/^(fa(-[0-9a-zA-Z]+)+)( (fa(-[0-9a-zA-Z]+)+)+)*$/i

And then set Apply text formatter to Yes, and then set Formatting Option to All lower-case in case someone enters a valid Font Awesome icon class, but uppercase.

  • Author

Thanks Ryan! That seems to have resolved the issue.

Recently Browsing 0

  • No registered users viewing this page.