Copy link to clipboard
Copied
Anyone know the Regex to find if a variable contains a word eg this var has "Surplus Percentage Total in the Amount of $2000.00"
So I need to know it contains the word 'Percentage'?
Here is my code
cfset xyz='Surplus Percentage Total in the Amount of $2000.00'
cfset foundword= REFind('Percentage',
xyz)
The above is not working
<cfset xyz='Surplus Percentage Total in the Amount of $2000.00'>
<cfset foundword = REFindNoCase('Percentage',xyz)>
<cfif foundword GT 0>
Word found at position <cfoutput>#foundword#</cfoutput>
<else>
Word not found
</cfif>
Copy link to clipboard
Copied
The code you displayed might not be the actual code. Where did those white things come from?
Copy link to clipboard
Copied
According to the docs, it will not return the subexpression unless you set the returnsubexpression flag to true. If the flag is false (default), it retuns an array of length and position of the subexpression.
^_^
Copy link to clipboard
Copied
<cfset xyz='Surplus Percentage Total in the Amount of $2000.00'>
<cfset foundword = REFindNoCase('Percentage',xyz)>
<cfif foundword GT 0>
Word found at position <cfoutput>#foundword#</cfoutput>
<else>
Word not found
</cfif>
Copy link to clipboard
Copied
Thanks.... implemented already with the RefindNocase. The values were coming in either lower/Upper case realized I have to use RefindNocase