View Single Post
  #24  
Old 01-08-2006, 01:15 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by ApothiX
Return the delimiters? Why would you want that? Just add them manually to whatever you're doing if you need them that badly.

I, for one, would rather not have commas and other crap in my tokens to make them look ugly :|
you seriously underestimate their usefulness... although, i did make a function that does it in a really really ugly sense... kindof taking advantage of how string lists are interpreted as arrays.

PHP Code:
function tokenizeWithDelims(string,delims) {
  
temp.list = "";
  for (
i=0i<string.length(); i++) {
    if (
delims.pos(string.charat(i)) == -1)
      
temp.list @= string.charat(i);
    else {
      if (
!= 0)
        
temp.list @= ",";
      
temp.list @= string.charat(i);
      if (
!= string.length()-1)
        
temp.list @= ",";
    }
  }
  return 
temp.list;

Reply With Quote