---
title: 202208 のの会@関数Talk 38th | Talks around @Functions in Notes and Domino
tags:  #domino #notes #lotus notes #dominoforever #のの会 #@関数 #hcl domino #hcl digital solutions #hcl notes #@replace #@replacesubstring #rem  
author: [あう゛](https://www.docswell.com/user/abesat)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/4JZGGM5373.jpg?width=480
description: Notes/Dominoの@関数を取り上げながら、調べたこと、経験したことを雑談してゆきます。  第38回は @Replace、@ReplaceSubstring と REM について
published: December 13, 23
canonical: https://www.docswell.com/s/abesat/ZGX469-202208-function-talk-38th
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/4JZGGM5373.jpg)

@
-notes knows community- 2022/08/10
@関数Talk
第38回
公開版
@
Talks around @Functions in Notes and Domino
✔ @Replace ✔ @ReplaceSubstring
阿部 覚
38th
✔ REM
(tw:) @abesat


# Page. 2

![Page Image](https://bcdn.docswell.com/page/YE6YYN9ZJV.jpg)

@
ひきつづき…
@


# Page. 3

![Page Image](https://bcdn.docswell.com/page/GE5GG5N9E4.jpg)

@
@ReplaceSubstring
で放談
@


# Page. 4

![Page Image](https://bcdn.docswell.com/page/972YYN557R.jpg)

@
前回の復習…部分文字列の置き換えを行う関数でした
@ReplaceSubstring
(&quot;Apple Pie&quot;:&quot;Bananas&quot;:&quot;Apple&quot;:&quot;Apple Juice&quot;:&quot;Nuts&quot;;
これが
あったら
&quot;Apple&quot;;
&quot;Orange&quot;)
これに置き換えてね
戻り値の表示例
@
元の文字列にAppleがあればOrangeに変わります
Apple Pie も Orange Pie に
Apple Juice も Orange Juice に変わっちゃいます


# Page. 5

![Page Image](https://bcdn.docswell.com/page/DJYGGPK6JM.jpg)

このページも前回スライドのパクリ復習です、
@
AppleがOrangeに、Apple Juice が Orange Juice に
変わるのはいいけど
Apple Pie は例外だよ、そのままにしたいという場合
こうやって戻すことならできそうですね
@ReplaceSubstring
(&quot;Apple Pie&quot;:&quot;Bananas&quot;:&quot;Apple&quot;:&quot;Apple Juice&quot;:&quot;Nuts&quot;;
&quot;Apple&quot;:&quot;Orange Pie&quot;;
&quot;Orange&quot;:&quot;Apple Pie&quot;)
戻り値の表示例
@


# Page. 6

![Page Image](https://bcdn.docswell.com/page/V7NGG5Z1E8.jpg)

@
@Replace のときと同様に
置換前と置換後のリストは
同一順序のものどうしが対応しています
@ReplaceSubstring
(&quot;A B C D E F G H I J K L M&quot;;
&quot;B&quot;:&quot;M&quot;;
&quot;V&quot;:&quot;W&quot;)
戻り値の表示例
@


# Page. 7

![Page Image](https://bcdn.docswell.com/page/YJ9WWYZYJ3.jpg)

@
したがって、楽屋ネタで恐縮ながら
こんな例でも
@ReplaceSubstring(&quot;I like OnTime.&quot;;
&quot;like&quot;:&quot;Ontime&quot;:&quot;.&quot;;
&quot;love&quot;:&quot;Hayabusa&quot;:&quot;!&quot;)
@
戻り値、わかりますよね？


# Page. 8

![Page Image](https://bcdn.docswell.com/page/GJ8NN61KED.jpg)

@
そうです、こうなります!
@ReplaceSubstring(&quot;I like OnTime.&quot;;
&quot;like&quot;:&quot;Ontime&quot;:&quot;.&quot;;
&quot;love&quot;:&quot;Hayabusa&quot;:&quot;!&quot;)
戻り値の表示例
★大文字小文字の区別は存在します
@


# Page. 9

![Page Image](https://bcdn.docswell.com/page/LJLPP9QPER.jpg)

@
では、やはり同様に
置換前と置換後のリストの要素数が違ってたら？
@ReplaceSubstring
(&quot;A B C D E F G H I J K L M&quot;;
&quot;B&quot;:&quot;M&quot;:&quot;G&quot;;
&quot;V&quot;:&quot;W&quot;)
戻り値の表示例
@
置換前の方が多い場合は、
あぶれた分は、置換後リストの最後のものになります


# Page. 10

![Page Image](https://bcdn.docswell.com/page/47M44Z12EW.jpg)

@
@ReplaceSubstring
(&quot;A B C D E F G H I J K L M&quot;;
&quot;B&quot;:&quot;M&quot;;
&quot;V&quot;:&quot;W&quot;:&quot;X&quot;)
戻り値の表示例
置換後の方が多い場合は、
あぶれた分はやはり無視されました
@


# Page. 11

![Page Image](https://bcdn.docswell.com/page/P7RWW6L5E9.jpg)

@
こんなこともやってみました
@ReplaceSubstring
(&quot;A B C D E F G H I J K L M&quot;:&quot;&quot;;
&quot;B&quot;:&quot;M&quot;:&quot;&quot;;
&quot;V&quot;:&quot;W&quot;:&quot;X&quot;)
戻り値の表示例
@
あくまで部分文字列の置換であるこの関数にとって
&quot;&quot;は対象外のようです


# Page. 12

![Page Image](https://bcdn.docswell.com/page/PJXPPMWXEX.jpg)

@
これが@Replace だったら｡｡｡
@Replace
(&quot;A B C D E F G H I J K L M&quot;:&quot;&quot;;
&quot;B&quot;:&quot;M&quot;:&quot;&quot;;
&quot;V&quot;:&quot;W&quot;:&quot;X&quot;)
戻り値の表示例
@
文字列全体を見比べて置換するので、
この例で実際に変換されるのは &quot;&quot; だけです


# Page. 13

![Page Image](https://bcdn.docswell.com/page/3JKDDGV97D.jpg)

@
と、ここまで確認したところで
@Replace と @ReplaceSubstring をあらためて
比べてみます
@Replace
@ReplaceSubstring
1 置換対象
全体
部分
2 置換前リストの数が置換
後より多いとき
あぶれた分は&quot;&quot;に置換 あぶれた分は置換後
リストの最後に合わ
せる
3 置換後リストの数が置換
前より多いとき
あぶれた分は無視
4 置換結果を後続のリスト
でさらに置換
しない
5 おまけ
&quot;&quot; も置換するよ
@
する
&quot;&quot; はありえ～ん！


# Page. 14

![Page Image](https://bcdn.docswell.com/page/LE3RRNM975.jpg)

@
しかし相違する部分は結局、
全体を置換する @Replace と
部分を置換する @ReplaceSubstring という
基本機能のちがいに由来するものだと思えます
@Replace
@ReplaceSubstring
1 置換対象
全体
部分
2 置換前リストの数が置換
後より多いとき
あぶれた分は&quot;&quot;に置換 あぶれた分は置換後
リストの最後に合わ
せる
3 置換後リストの数が置換
前より多いとき
あぶれた分は無視
あぶれた分は無視
4 置換結果を後続のリスト
でさらに置換
しない
5 おまけ
&quot;&quot; も置換するよ
@
する
&quot;&quot; はありえ～ん！


# Page. 15

![Page Image](https://bcdn.docswell.com/page/8EDYYW68EG.jpg)

@
なお、@ReplaceSubstring の実際の使用シーンとしては
「特殊文字部分の変換」が多いと思います
@ReplaceSubstring(PhoneNumber;
”-”:&quot;(&quot;:&quot;)&quot;;
&quot;&quot;)
@
たとえばこちら👆は
電話番号からハイフンやカッコを取り除いています


# Page. 16

![Page Image](https://bcdn.docswell.com/page/V7P669YWJ8.jpg)

@
さて、
これでお伝えしたいことはだいたい済んだんだけど
まだページが余ってる？なあ。。
そういえばこのところ、
&quot;re&quot;を究めることになってたから。。
@


# Page. 17

![Page Image](https://bcdn.docswell.com/page/2JV33MG9EQ.jpg)

@
REM
@
で放談


# Page. 18

![Page Image](https://bcdn.docswell.com/page/5EG33G847L.jpg)

@
以前にもSELECTなどを扱いましたが
式言語での「キーワード」も
ヘルプ上で
@関数の一覧に含まれています
@


# Page. 19

![Page Image](https://bcdn.docswell.com/page/4JQ55X9R7P.jpg)

@
REM はこんな書式で
式の動作とは関係なくコメントを加えておくものですね
@
基本 REM に続いて「&quot;」で囲んだコメントを
自由に入力します。
ただ、コメント内で「&quot;」を使いたい時があり


# Page. 20

![Page Image](https://bcdn.docswell.com/page/K74996XQE1.jpg)

@
たとえば式自体の一部を何等かの都合でREM文とし、
コメントアウトしようというとき
「&quot;」で囲もうとすると、
もとの式に含まれる「&quot;」を
「\&quot;」に変更する必要が生じてしまいます
@


# Page. 21

![Page Image](https://bcdn.docswell.com/page/LJ1KKVNL7G.jpg)

@
「{」「}」で囲む場合は、
そうした配慮が不要となります
@


# Page. 22

![Page Image](https://bcdn.docswell.com/page/GJWDDL4Q72.jpg)

@
さて、同じことは
REM だけでなく、通常の式内の文字列についても
いちおう言えます
式を記述した当初だけは。。。
@


# Page. 23

![Page Image](https://bcdn.docswell.com/page/4EZGGM23J3.jpg)

@
設計要素を一度保存してから、再度開くと
REMのほうはそのままなのに
式内の文字列は勝手に&quot;&quot;で囲まれた形式に
変換されてしまいます
@
あとからメンテナンスしづらいので
これ、REM と同じ仕組みにしてくんないかなぁ…
と思う次第です


# Page. 24

![Page Image](https://bcdn.docswell.com/page/Y76YYNVZEV.jpg)

@
今回もお付き合い
ありがとうございました 😀
@


