1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<?php $str = "1.2.3.4.5" ; $strs1 = explode ( "." , $str ); foreach ( $strs as $i ){ echo $i . "\n" ; } /* 输出结果为 1 2 3 4 5 */ ?> |
1
2
3
4
5
6
7
|
<script> str = "1.2.3.4.5" ; strs = str.split( "." ); for (i in strs){ document.write(strs[i]+ "<br>" ); } </script> |
1
2
3
4
5
|
$str = "1.2.3.4.5" ; @strs = split (/\./, $str ); #注意反斜杠 foreach $i ( @strs ) { print $i . "\n" ; } |
1
2
3
4
|
str = "1.2.3.4.5" strs = str .split( "." ) for i in strs: print (i) |
1
2
3
4
5
|
String str= "1.2.3.4.5" ; String[] strs=str.split( "." ); for (String i : strs) { System.out.println(i); } |
1
2
3
4
5
6
7
8
9
|
str= "1.2.3.4.5" oldIFS=”$IFS” IFS= "." strs=($str) IFS=”$oldIFS” for i in ${strs[@]} do echo $i done |
1
2
3
4
5
6
|
str= "1.2.3.4.5" strs=($( tr "." " " <<< $str)) for s in ${strs[@]} do echo $s done |
1
2
3
4
5
|
$str = "1.2.3.4.5" $strs = $str .split( "." ) foreach ( $i in $strs ){ echo $i } |
1
2
3
4
5
6
7
8
9
10
|
@echo off set a=1.2.3.4.5 for /f "delims=. tokens=1-5" %%i in ( "%a%" ) do ( echo %%i echo %%j echo %%k echo %%l echo %%m ) pause |
原文出自:
http://blog.too2.net/?p=214
转载请注明转自:辛碌力成【http://blog.too2.net】
发表评论