Jump to content

Recommended Posts

Posted (edited)

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
Posted

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"?

Posted
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.

  • Solution
Posted

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...