perl 文字列処理関数 split 2
#split関数を使ってスペース文字の前後の文字列を取り出す print "文字列を入力してください>"; $string = <STDIN>; chomp($string); #スペース文字で2つに区切る ($pre, $post) = split(/\s+/, $string, 2); #スペース文字の前後の文字列を表示 print "最初の文字列:$pre\n"; print "後の文字列:$post\n"; #実行結果 # 文字列を入力してください>perl is a Practical Extraction and Report Language # 最初の文字列:perl # 後の文字列:is a Practical Extraction and Report Language
- 作者: Randal L. Schwartz,brian d foy,Tom Phoenix,近藤嘉雪
- 出版社/メーカー: オライリージャパン
- 発売日: 2012/07/25
- メディア: 大型本
- 購入: 7人 クリック: 22回
- この商品を含むブログ (17件) を見る