JavaScript String Tokenizer
Input String:
Welcome to "JavaScript String Tokenizer": ========================================= "JavaScript String Tokenizer" extends JavaScript strings by the "tokenize()" method, that allows you to break a string into an array of string tokens. It has the following syntax: var tokens = myString.tokenize(separator, trim, ignoreEmptyTokens); where - string myString: is the string to be breaked into several substrings - string separator is the string that seperates the tokens - string trim is the string (repetition) that will be omitted when leading or trailing a token - boolean ignoreEmptyTokens is a flag to indicate whether or not empty ("") string tokens shall be added to the returned array - Array tokens is an array of strings that contains the returned tokens "JavaScript String Tokenizer" may be either used with this web interface or in your own JavaScript code. This is what your code might look like: <script type="text/javascript" src="Tokenizer.js"></script> <script type="text/javascript"> var myString = "These, are, comma, separated, tokens, and, whitespaces, will, be, omitted"; var tokens = myString.tokenize(",", " ", true); for(var i=0; i<tokens.length; i++) window.alert(i + ". token: " + tokens[i]); </script>
Input-Seperator:
Trim:
Output-Seperator:
Ignore Empty Tokens
Tokens:
Paste your input string in the upper textarea. Set your configuration at the right side and press the "Tokenize" Button. The string tokens will be displayed here.
Control Character:
\n
= new line
\t
= tabulator
\f
= form feed
\b
= backspace
\r
= carriage return