Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.string.tokenize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.string.tokenize"] = true;
3
dojo.provide("dojox.string.tokenize");
4
 
5
dojox.string.tokenize = function(/*String*/ str, /*RegExp*/ re, /*Function?*/ parseDelim, /*Object?*/ instance){
6
	// summary:
7
	//		Split a string by a regular expression with the ability to capture the delimeters
8
	// parseDelim:
9
	//		Each group (excluding the 0 group) is passed as a parameter. If the function returns
10
	//		a value, it's added to the list of tokens.
11
	// instance:
12
	//		Used as the "this" instance when calling parseDelim
13
	var tokens = [];
14
	var match, content, lastIndex = 0;
15
	while(match = re.exec(str)){
16
		content = str.substring(lastIndex, re.lastIndex - match[0].length);
17
		if(content.length){
18
			tokens.push(content);
19
		}
20
		if(parseDelim){
21
			var parsed = parseDelim.apply(instance, match.slice(1));
22
			if(typeof parsed != "undefined"){
23
				tokens.push(parsed);
24
			}
25
		}
26
		lastIndex = re.lastIndex;
27
	}
28
	content = str.substr(lastIndex);
29
	if(content.length){
30
		tokens.push(content);
31
	}
32
	return tokens;
33
}
34
 
35
}