Drkcore

29 09 2007 perl Tweet

Regexでマッチした位置を返す

gオプションをつけておけばposという組み込み関数が使える

pirl @> $text = "abcde"
"abcde"

pirl @>  pos($text) if $text =~ /c/
undef

pirl @>  pos($text) if $text =~ /c/g
3

といまさらながら知った。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021