the singularity of being and nothingness
Java String Methods in ColdFusion
This is nothing new or shocking, but I thought I’d post it anyway. When you’re dealing with ColdFusion content, you have available a number of exposed Java string methods that can be used in addition to the functions that CF provides. You don’t have to invoke any Java objects or nonsense like that–simply call the method and see what happens.
Of course, many from the full list of Java string methods are either already familiar via CF functions or can be replicated quite easily by CF-only functions. Nonetheless, I thought I’d share a quick roundup of what I think are some of the more interesting, along with simple examples of how to use them. I hope you enjoy this Bleach-inspired sampling 🙂
Method | Code | Result |
---|---|---|
charat |
value = 'Bleach is awesome'; value.charat(3); |
3 |
concat |
value = 'Bleach is awesome'; addtl = ' because of the epic battle sequences'; value.concat(addtl) |
Bleach is awesome because of the epic battle sequences |
contains |
value = 'Ichigo Kurosaki'; value.contains('saki'); |
Yes |
endswith (case sensitive) |
value = 'Zanpakutou'; value.endswith('tou'); |
Yes |
lastindexof |
value = 'You can catch new episodes of Bleach on crunchyroll.com, but only if you have a membership for which you pay each month'; value.lastindexof('you'); |
101 |
split |
value = 'Shinigami|Bount|Hollow'; value.split('|'); |
[Shinigami,Bount,Hollow] |
startswith (case sensitive) |
value = 'Zanpakutou'; value.startswith('zan'); |
No |
Print article | This entry was posted by existdissolve on June 29, 2010 at 12:41 pm, and is filed under ColdFusion. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |