Jump to content

Tokenize a string: Difference between revisions

m
Changed over to works with template
m (Changed over to works with template)
Line 24:
=={{header|C}}==
 
'''Standard:'''{{works with|ANSI C}}
{{works with|gcc|3.3.3}}
 
'''Compiler:''' [[gcc]] 3.3.3
 
{{libheader|POSIX}}
 
Line 67 ⟶ 65:
=={{header|C++}}==
 
'''Standard:'''{{works with|ANSI C++}}
'''Compiler:''' [[GCC]]{{works with|g++ (GCC) |3.4.4 (cygming special)}}
 
'''Compiler:''' [[GCC]] g++ (GCC) 3.4.4 (cygming special)
 
{{libheader|STL}}
 
Line 190 ⟶ 186:
 
=={{header|Java}}==
{{works with|Java|1.0+}}
'''Compiler:''' JDK 1.0 and up
 
There are multiple ways to tokenize a String in Java. The first is by splitting the String into an array of Strings, and the other way is to use StringTokenizer with a delimiter. The second way given here will skip any empty tokens. So if two commas are given in line, there will be an empty string in the array given by the split function, but no empty string with the StringTokenizer object.
Line 209 ⟶ 205:
 
=={{header|JavaScript}}==
'''Interpreter:'''{{works with|Firefox |2.0}}
 
alert( "Hello,How,Are,You,Today".split(",").join(".") );
Line 222 ⟶ 218:
 
=={{header|Perl}}==
{{works with|Perl|5.X}}
'''Interpreter:''' [[Perl]] any 5.X
 
As a one liner without a trailing period, and most efficient way of doing it as you don't have to define an array.
Line 239 ⟶ 235:
 
=={{header|PHP}}==
{{works with|PHP|5.x}}
'''Interpreter:''' [[PHP]] any 5.x
 
<?php
Line 290 ⟶ 286:
 
=={{header|Python}}==
'''Interpreter:'''{{works with|Python |2.5}}
 
text = "Hello,How,Are,You,Today"
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.