Link to home
Start Free TrialLog in
Avatar of LeadCo
LeadCo

asked on

How do I parse to see if the word copay is in a variables content

I am doing a database query and pulling the variable "copay" whis is text that describes the benefits of the copay benefit for an insurance plan.

So copay may = "Not Covered" or "$35 copay after deductible" etc.

What i want to do is set a variable based on if the variable "copay" contains the word copay in it.

<cfif copay contains "copay" word> (I have no idea)
<cfset iscopay = 1> <cfelse>cfset iscopay = 0>
</cfif>
SOLUTION
Avatar of duncancumming
duncancumming
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you need the exact word and NOT any words that contain it, you better use REFindNoCase():

something like this:
<cfset iscopay = REFindNoCase(copay, "\Bcopay\B")>

copay will be 0 if not found or a number representing position of work 'copay' in the string if found
(\B is a regex word boundary)

Azadi
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeadCo
LeadCo

ASKER

Thanks Guys wish I could all of you 500 points. They are all correct.