[SalesForce] Using REGEX in Visualforce

I want to be able to render an element if my custom field matches a certain pattern.

Custom Field Name: Code__c
Pattern: (any character)19-10-11-12(any character)

How can this be achieved in Visualforce?

The rendered condition in my below code does not evaluate true. Please help.

My code below –

<apex:outputPanel rendered="REGEX(Code__c, '[a-zA-Z]+19-10-11-12[a-zA-Z]+')">

...

</apex:outputPanel>

Best Answer

You have to use the expression syntax when calling the functions

<apex:outputPanel rendered="{!REGEX(Code__c, '[a-zA-Z]+19-10-11-12[a-zA-Z]+')}">

But the REGEX function is not available in Custom Formula Fields or Visualforce. check this reference

So you have to either move this logic into the controller or try using javascript to render this.

Related Topic