No intentions of undermining the Regex ninja, I just like (and need) the
regex practice.
 
<cfscript>
        function getval(str){
        str = rereplacenocase(str, "((FirstName: |LastName: |Age:
)+([\w]+[^[:space:]]))", "<b>[\1]</b>", "ALL");
        return str;
        }
</cfscript>

<cfset content = "Text text text text text text text
FirstName: Bob Age: 30 text text text
text text text text text LastName: Brown text text text text text 
FirstName: Ted Age: 30 text text text">


<cfoutput>#getval(content)#</cfoutput>

The \2 would be the FirstName:  or Age:  ect... the \3 is the value
immediately following it and \1 is the whole sting (eg. Firstname: Bob).
Once they are found the rest should be easy and up to you. You could wrap
them in brackets to make it easier to pull out, modify it a little to
replace everything but \1. Guess it just depends on what you want in the end


-----Original Message-----
From: Burns, John D [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 21, 2004 12:26 PM
To: CF-Talk
Subject: RegEx help

I'm trying to parse through some information in a text document where
there is information like this:
 
Text text text text text text text
FirstName: Bob Age: 30 text text text
text text text text text LastName: Brown text text
text text text
 
but this information is also within a bunch of other text.  I was
attempting to do a find() for the "field" I was looking for and then do
other finds for the spaces and such, but it was getting pretty
confusing.  I was thinking about writing a RegEx where I could plug in
the field name and it would find the field name followed by a colon and
a space and grab the next value until the next space is encountered.  I
know that the field names will always be followed by a colon and a space
and that the value for that field will never have a space in it and the
end of the value will be a space.  Does this make sense?  If so, could
anyone get me started on the right track?  I want to use reReplace to
get rid of everything except the value that I'm trying to get.  Am I way
off?  Is there an easier way?
 
John Burns




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF 
community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=37

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182277
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to