[過去ログ] Regular Expression(正規表現) Part15 (1002レス)
上下前次1-新
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
712(1): デフォルトの名無しさん [sage] 2021/06/28(月)20:50 ID:quG4wdoj(1)
Ruby で作ってみた
# 最後のドットと、_ の間の文字列を抜き出す。該当なしなら、nil を返す
def slice_string( input_str )
pos_1 = input_str.rindex( "." ) # 文字列の末尾から探す
return nil unless pos_1
pos_2 = input_str.index( "_", pos_1 + 1 ) # ドットの次の文字から探す
return nil unless pos_2
return input_str.slice( pos_1 + 1 ... pos_2 )
end
input_ary = %w(.foo.xxx_var .foo.foo.yyy_var .zz zz)
p input_ary.map{ |str| slice_string( str ) }
#=> [ "xxx", "yyy", nil, nil ]
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.030s