日本語プログラミング言語なでしこの公式掲示板

なでしこ1 質問

トップ 新規 検索

2022-03-07 17:05:32

正規表現置換とファイルの上書きについて。

特明 さん

こんにちは、初心者です。
txtフォルダの中身を改変し、クリップボードに保存後、中身を消去(空っぽ)にするソフトウェアを作りたいです。 (知恵袋でも質問しました。 )
以下のようなコードを組んだのですが、(1)の文章が(2)のように変化してしまい、正規表現置換がうまくいきません。
正規表現で検索されたものをもとに、「改行」だけを消し半角スペースに置き換えたいのですが、どのようにすればよいのでしょうか?
また、編集元の「test.txt」をまっさらな状態で上書きする方法がわかりません。
無知蒙昧で申し訳ありませんが、ご教授いただけると幸いです。


「C:\Users\Desktop\test.txt」を開く。
 それの、
『{i}』を「」に置換
『{/i}』を「」に置換
『{b}』を「」に置換
『{/b}』を「」に置換
    「.\n[a-z]」を「.\s[a-z]」へ正規表現置換。

 
内容=それ
内容をコピー
#-----------------------------------------------------------------------
# 以下、確認画面
#-----------------------------------------------------------------------

以下がクリップボードにコピーされています。
-------------------------------------------

{内容}
」のメモ記入。

終わり。




────────────────────────────────────
(1)

This is a sample text message.

If you select {i}Delimited text{/i}, a Microsoft Notepad page
opens with sample text.

For this {b}reason{/b} we filter out vectors with sample text,
instructions and any other text that isn't a core part of the design.

Choice: Displays the sample text spoken by the TTS playback voice.
Choice: If there is sample text on the label, click it.
Choice: Just choose the appropriate setting from a list and evaluate the presentation
of the sample text in the Preview area.
Choice: This sample text illustrates the current settings. You may edit it to test special characters.

Player chose: Just choose the appropriate setting from a list and evaluate the presentation
of the sample text in the Preview area.

To provide this list, replace the sample text in the Type each choice
on a separate line box with the values that you want.

────────────────────────────────────
(2)

This is a sample text message.

If you select Delimited text, a Microsoft Notepad page.s[a-z]pens with sample text.

For this reason we filter out vectors with sample text,.s[a-z]nstructions and any other text that isn't a core part of the design.

Choice: Displays the sample text spoken by the TTS playback voice.
Choice: If there is sample text on the label, click it.
Choice: Just choose the appropriate setting from a list and evaluate the presentation.s[a-z]f the sample text in the Preview area.
Choice: This sample text illustrates the current settings. You may edit it to test special characters.

Player chose: Just choose the appropriate setting from a list and evaluate the presentation.s[a-z]f the sample text in the Preview area.

To provide this list, replace the sample text in the Type each choice.s[a-z]n a separate line box with the values that you want.

────────────────────────────────────


(編集パスワード送信)

親記事

この内容(No.1244)に返信

この内容(No.1244)の関連リンク

この内容(No.1244)をダウンロード

この内容(No.1244)のテキスト表示

子記事

1247 Re②:正規表現置換とファイルの上書きについて。 (22-03-08)
1246 Re①:正規表現置換とファイルの上書きについて。 (22-03-07)
1245 Re①:正規表現置換とファイルの上書きについて。 (22-03-07)




www.eznavi.net