Search code examples
regexcfml

Match year in string (REGEX)


I have some data like:

10/2015
11/2020
09/2016
01/2014

I want to match everything that is > 2014 (in the future) so I try to use REGEX:

<cfif Refind("201[5-9]|202[0-9]|203[0-9]", Date) eq 1>
<!--- dosmth --->
</cfif>

I tried also:

<cfif Refind("201[5-9]$|202[0-9]$|203[0-9]$", Date) eq 1>
<!--- dosmth --->
</cfif>

Doesn't match anything. What am I missing? Thanks!


Solution

  • Found it.

    <cfif Refind("^[0-9]{2}\/(201[5-9]|202[0-9]|203[0-9])$", Date) eq 1>