I believe REfind will only return one instance of the RE at a time so you
have to loop over it to return all instances.
see article at:
http://www.cfcomet.com/cfcomet/Other/index.cfm?ArticleID=F0A14065-EF7A-4A9E-
AED5F28EF8C19D65
I adapted this from a piece of code I am using on CFWiki. It seems to do the
trick.
<cfset Attributes.testTxt = "This is line 1 " & chr(10) &
"This is line 2 " &
chr(10) &
"This is line 3 " &
chr(10) &
"This is line 4 " &
chr(10) &
"This is line 5 " &
chr(10) &
"This is line 6 " &
chr(10) &
"This is line 7 " &
chr(10) &
"This is line 8 " &
chr(10) &
"This is line 9 " &
chr(10) &
"This is line 10 " >
<cfset Variables.startPos = 1>
<cfset Variables.stillChecking = 1>
<cfset Variables.testRE = chr(10)>
<cfset Variables.testCount = "0">
<!--- loop through testTxt looking for testRE --->
<cfloop condition="Variables.stillChecking">
<cfset testLoc = REFind(testRE, Attributes.testTxt, Variables.StartPos,
TRUE)>
<!--- if a testRE exsists... --->
<cfif testLoc.pos[1]>
<!--- Count it --->
<cfset Variables.testCount = Variables.testCount + 1>
<!--- move beyond the testRE and keep checking--->
<cfset Variables.startPos = testLoc.pos[1] + testLoc.len[1]>
<cfelse>
<!--- if no testRE are left quit loop --->
<cfset Variables.stillChecking = 0>
</cfif>
</cfloop>
<cfoutput>
<p>#Attributes.testTxt#
<p>There are #Variables.testCount# instances of #Variables.testRE# in
this
string
</cfoutput>
Brian Shearer
Custom Data Systems, Inc.
http://www.cdsi-solutions.com/cfwiki
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 09, 2001 1:39 PM
To: Fusebox
Subject: Re: Slightly OT question ...
Hi David,
I just wanted to let you know that I appreciate the new information on
the :space: paramater of the ReFindNoCase function.
I am still struggling with trying to get the function to return a structure
with more then one instance of what I am looking for.
For example. If I understand the help files of CF Studio ReFindNoCase
should be able to create a structure like this:
st.pos[1] = 1
st.len[1]=10
st.pos[2]=15
st.pos[2]=5
st.pos[3]=34
st.len[3]=26
.........
etc.
of whatever type of character you are looking for.
I must be misunderstanding how this function works because I can not
seem to get it to perform in this manner even though the documentation
looks like it will produce the result above. I can only get it to come
back with one set of the .pos and .len elements.
Anyway, thanks again for the information, it was definately helpful to
know.
Cheers
Ryan Williams
"David Huyck"
<b@bombusbee. To: Fusebox
<[EMAIL PROTECTED]>
com> cc:
Subject: Re: Slightly OT
question ...
05/09/01
12:49 PM
Please
respond to
fusebox
the regEx escape charqacter for spaces in CF is [:space:]. So you would
do:
<cfset st=REFindNoCase("[[:space:]]+",
qGet_MeetingMinutes.MM_BodyOfMeeting,1,"TRUE")>
To find "hard returns" I would look for CRLFs (carriage return/line feeds)
by
doing:
FindNoCase("#char(13)##char(10)#", ...) I'm not sure what the regular
expression equiv would be off the top of my head.
HTH,
David Huyck
[EMAIL PROTECTED]
| Here is a snippet of my current code.
|
| <cfset st=REFindNoCase("([ ])
| +(\1)",qGet_MeetingMinutes.MM_BodyOfMeeting,1,"TRUE")> (this line was my
| attempt at finding blank spaces longer then 1 space within the text
string
| - it didnt work.)
| <cfset request.RowNum=(len(qGet_MeetingMinutes.MM_BodyOfMeeting)/66)+3>
|
| <textarea name="BodyOfMeetingMinutes" cols="66" rows="#request.RowNum#"
| wrap="soft">#trim(qGet_MeetingMinutes.MM_BodyOfMeeting)#</textarea>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists