Tokenize a string: Difference between revisions
Content added Content deleted
(added Crystal implementation) |
No edit summary |
||
Line 1,822: | Line 1,822: | ||
{{out}} |
{{out}} |
||
<pre>Hello.How.Are.You.Today</pre> |
<pre>Hello.How.Are.You.Today</pre> |
||
=={{header|Ksh}}== |
|||
<lang ksh> |
|||
#!/bin/ksh |
|||
# Tokenize a string |
|||
# # Variables: |
|||
# |
|||
string="Hello,How,Are,You,Today" |
|||
inputdelim=\, # a comma |
|||
outputdelim=\. # a period |
|||
# # Functions: |
|||
# |
|||
# # Function _tokenize(str, indelim, outdelim) |
|||
# |
|||
function _tokenize { |
|||
typeset _str ; _str="$1" |
|||
typeset _ind ; _ind="$2" |
|||
typeset _outd ; _outd="$3" |
|||
while [[ ${_str} != ${_str/${_ind}/${_outd}} ]]; do |
|||
_str=${_str/${_ind}/${_outd}} |
|||
done |
|||
echo "${_str}" |
|||
} |
|||
###### |
|||
# main # |
|||
###### |
|||
_tokenize "${string}" "${inputdelim}" "${outputdelim}"</lang> |
|||
{{out}}<pre>Hello.How.Are.You.Today</pre> |
|||
=={{header|LabVIEW}}== |
=={{header|LabVIEW}}== |