Skip to content

Instantly share code, notes, and snippets.

@noqisofon
Created April 11, 2023 08:05
Show Gist options
  • Save noqisofon/dac6e4b0f25aef3787e3802ce07a6eb5 to your computer and use it in GitHub Desktop.
Save noqisofon/dac6e4b0f25aef3787e3802ce07a6eb5 to your computer and use it in GitHub Desktop.
( ノ╹◡◡╹)ノ 「いっぱい」の「い」を「お」に変えてみるテスト

「いっぱい」の「い」を「お」に変えてみよう。

my $phrase = 'いっぱい';

Raku 言語においては .subst メソッドを使うと文字列の置換を行うことができる。 早速やってみよう。

みんな大好き「おっぱい」になるのは最初の「い」を「お」に変えたときだ。

say $phrase.subst( //, '' );     # prints: おっぱい

全ての「い」を「お」に変えると、残念なことに「いっぱい」は「おっぱお」に変わってしまう。

say $phrase.subst( //, '', :g ); # prints: おっぱお
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment