Coast Line
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
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
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?
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?
ASKER
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:
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">
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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
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?
ASKER
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"
.. oral=UNCONTROLLED**CPT Codes= 0239T : BIOIMPEDANCE SPECTROSCOPY - 07/31/2013**CPT Codes= 10022 : FNA W/IMAGE - 07/31/2013"
ASKER
yes
ASKER
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,11 2.8,111.0>
<cfsety string2 = 'Pneumonia due to Candida= UNCONTROLLED,Candidiasis, oral= UNCONTROLLED,Brucella canis infection= UNCONTROLLED,Brucella canis infection= UNCONTROLLED'>
<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,11
<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="#yourNewDelimi ter#">
....
<cfloop list="#string#" index="elem" delimiters="#yourNewDelimi
....
10022 : FNA W/IMAGE - 07/31/2013
or just the 10022
?