When I put in the found.pos[1]-1 I get You have attempted to dereference a
scalar variable of type class java.lang.Integer as a structure with members
Whatever that is supposed to mean?
Looks like my last reply was truncated. (Out of curiosity, I am
resending a cfscript version to see
Did you forget to modify reFind so it returns subexpressions (ie a structure
not a number)?
ie found = REFind(url.terms, DocContents, startAt, TRUE );
-Le
~|
Order the Adobe Coldfusion Anthology now!
ie found = REFind(url.terms, DocContents, startAt, TRUE );
-Le
lol.. Even my name is being truncated ;
~|
Order the Adobe Coldfusion Anthology now!
That did get rid of the error but now it isn't inserting anything. It appears
to be ignoring the statement altogether.
~|
Order the Adobe Coldfusion Anthology now!
It sounds like something else is missing. Can you post your current code?
-Leigh
~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
I've been banging my head on this all day. All I want to do is put a number to
the left of each word that I find in my document so that I can eventually turn
those into links to jump from one match to the next. I have it partially
working. Here is my code:
cfset getMatches =
The docs for REFind() say that the third argument should be a positive
integer, default value is 1.
REFind() returns the position in the string where the matched string
begins. You'll need to add the length of the matched string (in your
case, Len(url.terms) ) to this value to get the end of
Thanks Carl,
Now it just ignores it altogether and doesn't put any number in at all.
~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
inserts the number in the wrong spot.
Insert adds the string *after* the given position, not before. So you need to
deduct 1 from the result of reFind()
~|
Order the Adobe Coldfusion Anthology now!
REFind( url.terms, DocContents, ...)
Also the code probably will not behave as expected if you are searching for
partial words. Since you are searching starting from the beginning of the
string each time, rather than the last occurrence.
So, any suggestions how to go about that? I just want to highlight words in a
searched document and allow the user to go to next and previous match in long
documents. I thought adding a a href=#uniqueNumber# would be a good way
using an Insert function. Now, I'm clueless on how to go about
A lot depends on the search pattern. But as you loop keep track of where the
previous occurrence was found. Then start searching *after* that position.
Otherwise, refind will just return the first occurrence over and over again.
You can use the fourth parameter of reFind to get the position
Looks like my last reply was truncated. (Out of curiosity, I am resending a
cfscript version to see if the lack of tags makes a difference.)
cfscript
startAt = 1;
for (i = 1; i = ArrayLen(getMatches); i++) {
found = REFind(url.terms, DocContents, startAt, true);
//
13 matches
Mail list logo