Link to home
Create AccountLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

string extraction

Hi Experts,

I have the following string:

<cfset string = "023.3 : Value 1= UNCONTROLLED,112.4 : Pneumonia due = UNCONTROLLED,112.0 : Candidiasis, oral= UNCONTROLLED,CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013,CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013">

I want to extract the CPT Codes into new variables:

like string1 and string2, string 1 will hold the values for the above uncrolled and string 2 will hold cpt codes values

I am bit aware that this can somehow achieved though regex, but i am less in RegEx,

Just Guide me
Avatar of Tomarse111
Tomarse111
Flag of United Kingdom of Great Britain and Northern Ireland image

Is the CPT code the whole of:

10022 : FNA W/IMAGE - 07/31/2013

or just the 10022

?
Avatar of Coast Line

ASKER

full 10022 : FNA W/IMAGE - 07/31/2013
> string 1 will hold the values for the above uncrolled

Do you mean "uncontrolled"? It's repeated several times in the string.


<cfset string = "023.3 : Value 1= UNCONTROLLED,112.4 : Pneumonia due = UNCONTROLLED,112.0 : Candidiasis, oral= UNCONTROLLED,CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013,CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013">

Which instance do you want - and why ie what's the pattern?
I just want to fetch this

CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013,CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013 into separate string like below:

<cfset string = "023.3 : Value 1= UNCONTROLLED,112.4 : Pneumonia due = UNCONTROLLED,112.0 : Candidiasis, oral= UNCONTROLLED,CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013,CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013">

<cfset string1 = "023.3 : Value 1= UNCONTROLLED,112.4 : Pneumonia due = UNCONTROLLED,112.0 : Candidiasis, oral= UNCONTROLLED">

<cfset string2 = "CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013,CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013">

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
thanks, but i think comma is a very common separator, it may come in the when the cpt code is like this:

CPT Codes= 0239T : BIOIMPEDANCE,SPECTROSCOPY - 07/31/2013,CPT Codes= 10022 : FNA, W/IMAGE - 07/31/2013
Yeah, that's the problem with parsing free form strings.  In order to extract that right information, they must contain a *consistent* format or pattern.  Other than commas, what is the format of your string?
i can use any like an ascii character or *
Are you saying *you* can change the format to use "**" instead of commas?

.. oral=UNCONTROLLED**CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013**CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013"
yes
Also for this string:

<cfset string = "112.4 : Pneumonia due to Candida= UNCONTROLLED,112.0 : Candidiasis, oral= UNCONTROLLED,023.3 : Brucella canis infection= UNCONTROLLED,023.3 : Brucella canis infection= UNCONTROLLED,112.8 : Pneumonia due to Candida= UNCONTROLLED,111.0 : Candidiasis, oral= UNCONTROLLED">

How i can again subside it to make it work like this:

<cfset string1 = 112.4,112.0,023.3,023.3,112.8,111.0>
<cfsety string2 = 'Pneumonia due to Candida= UNCONTROLLED,Candidiasis, oral= UNCONTROLLED,Brucella canis infection= UNCONTROLLED,Brucella canis infection= UNCONTROLLED'>
If you can use any delimiter you want, there's no issue. Just change of the format of the string, and use that delimiter in the loop code:

        <cfloop list="#string#" index="elem" delimiters="#yourNewDelimiter#">
              ....