0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Powershell 今日のトリビア ドル記号を区切り文字にするときのエスケープはバッククォートではない

Posted at

ヒントはJava

Why can't I split a string with the dollar sign?
Javaはline.split("\\$");
これがヒント

その前にドル記号の文字列は必ずシングルクォーテーションで囲む

ダブルクォーテーションの場合変数と勘違いして展開するためです。
このへんはここを参照します。
about_Quoting_Rules (ver 7.3)

答えは

バッククォートではありません。
これも円記号(バックスラッシュ)になります。

$('$$eee$aaa$zzz') -split '\$'

または区切り文字をダブルクォーテーションで囲み

$('$$eee$aaa$zzz') -split "\$"

日本語環境だとカオスに

円ドルと記載するのでわけがわかりません。
まあドル記号は変数の印なので、パワーシェルで区切り文字に使うほうがおかしいのですが。
円記号が円でエスケープならドルはどうなるのか?ということで確認してみたところ判明しました。

image.png

How to express the dollar sign in string
英語ではExpressionというみたいですね。ドル記号はドルサイン。
意外とバッククォートでエスケープするのは限られています。そして機能があります。

`t # タブ記号
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?