Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
AcidGuy #1
last index of an ocurrence ???
hi guys !
is there a way to look to the last index of a character on a string, since i
have been checking the help on coldfusion mx and i can find the refence of
Find, and just works for searching the first ocurrence, and the last one ???
anyone can help ?
thx
AcidGuy Guest
-
Settle a debate - to index or not to index?
I have 2 tables: mysql> desc a; +---------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key |... -
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Hey Folks,(New to .NET) This is driving me NUTZ... If anyone out there can resolve this from me I would greatly appreciate it... Line 238: Line... -
Index Topics and Index References
Ok here is my problem. I Generate my Index and it keeps coming up with the original index i created. I went through all the chapters in my manual... -
Newb query: index.htm & index.php & the server default
The problem I'm trying to solve is as follows: The website has two subdirectories: /ordinary and /phpstuff. Users typing hostname/ordinary get the... -
Create index VS Set Index Enabled - IDS 7.31
Hi List, I am in the process of re-doing my production DB. One of the step I decide to perform was to "Set index enabled" instead of of... -
Adam Cameron #2
Re: last index of an ocurrence ???
> I don't know if there is a lastIndexOf function, but you could always
CF Strings extend Java Strings, so you can just use the lastIndexOf()
method of java.lang.String.
--
Adam
Adam Cameron Guest
-
Cannikinn #3
Re: last index of an ocurrence ???
You can always use REFind with "returnsubexpressions" set to "true". What this
does is return two arrays, one with the every position in the string that it
found your search term, and another with the length of the match. Once you get
that, just look at the last position. So you'd have something like:
<cfset theString = "Cats are cool. I like cats. Cats are my friends. How many
cats do you have?">
<cfset theMatch = "cats">
<cfset findResult = REFind(theMatch,theString,1,true>
So now findResult looks something like:
findResult.pos[1] = 1;
findResult.pos[2] = 23;
findResult.pos[3] = 29;
findResult.pos[4] = 59;
findResult.len[1] = 4;
findResult.len[2] = 4;
findResult.len[3] = 4;
findResult.len[4] = 4;
And if you wanted to know the position of the very last occurance, just go:
<cfset lastMatchPosition = findResult.pos[Len(findResult.pos)]>
Because Len(findResult.pos) will always return the index of the last match.
Hope that helps!
Cannikinn Guest
-
_jt #4
Re: last index of an ocurrence ???
I don't know if there is a lastIndexOf function, but you could always
reverse the string and find the first index. Then just adjust that number to
reflect the position from the end of the string.
"AcidGuy" <webforumsuser@macromedia.com> wrote in message
news:d72771$1r3$1@forums.macromedia.com...since i> hi guys !
>
> is there a way to look to the last index of a character on a string,???> have been checking the help on coldfusion mx and i can find the refence of
> Find, and just works for searching the first ocurrence, and the last one>
> anyone can help ?
>
> thx
>
_jt Guest
-
_jt #5
Re: last index of an ocurrence ???
Good tip!
"Adam Cameron" <adam_junk@hotmail.com> wrote in message
news:n9qiq392pwc8$.11zbyoqil6ku2.dlg@40tude.net...>> > I don't know if there is a lastIndexOf function, but you could always
> CF Strings extend Java Strings, so you can just use the lastIndexOf()
> method of java.lang.String.
> --
>
> Adam
_jt Guest



Reply With Quote

