[正規表現]Quotationクォテーションの置き換え
めったに無い英語系
慣れないので、戸惑う事が多い
『幸い』大量ページ物では無かったので、短時間で済んだが
用紙サイズはまだしも
禁則に関しては『何が正解』なんだか?状態で非常に難儀した
クオテーションの直しがあり
Jedit Xの複数置換で対応したが…
校正も初めての業者さんで、慣れないのもあり
ホント難儀した…
上のような原稿を
下のように置き換えます。
こんな感じです。
Jedit Xの置換ファイル
「ReplaceQuotation.txt」をダウンロード
実際には
赤字の部分のPRIME関連の置き換えは実施せずに
検索かけながらの手作業にした(結局は1カ所だけだった)
---
一応お約束でAppleScriptも作ったが
ファイル数が多くないならJedit Xの置換の方が堅い
set theText to "I'm \"NO, the is the 'Right Way!'\" she replied. 6' 2\" tall"
set theDoneReplace to doReplace(theText, " ", " ") as text
set theDoneReplace to doReplace(theText, "\\", "") as text
-----Apostrophe
set theDoneReplace to doReplace(theDoneReplace, "′", "'") as text
-----DoubleQuotation
set theDoneReplace to doReplace(theDoneReplace, " \"", " “") as text
set theDoneReplace to doReplace(theDoneReplace, "\" ", "” ") as text
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\" | awk 'gsub(/(\"$)/, \"”\") \"\"'"
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\" | awk 'gsub(/(^\")/, \"“\") \"\"'"
-----SingleQuotation
set theDoneReplace to doReplace(theDoneReplace, " '", " ‘") as text
set theDoneReplace to doReplace(theDoneReplace, "' ", "’ ") as text
set theDoneReplace to doReplace(theDoneReplace, "“'", "“‘") as text
set theDoneReplace to doReplace(theDoneReplace, "'“", "‘“") as text
set theDoneReplace to doReplace(theDoneReplace, "”'", "”’") as text
set theDoneReplace to doReplace(theDoneReplace, "'”", "’”") as text
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\"| awk 'gsub(/'\\''$/, \"’\" ) \"\"'"
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\" | awk 'gsub(/^'\\''/, \"‘\" ) \"\"'"
-----Prime
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\"| sed -e 's/\\([0-9]\\)\\(’\\)\\( \\)/\\1′\\3/g'"
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\"| sed -e 's/\\([0-9]\\)\\(”\\)\\( \\)/\\1′\\3/g'"
tell application "TextEdit" to launch
tell application "TextEdit"
make new document with properties {text:theDoneReplace}
tell document 1
properties
set font to "Georgia"
set size to 48
end tell
end tell
tell application "TextEdit" to activate
--------////////文字の置き換えのサブルーチン
to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace
| 固定リンク
「JeditX Regexp」カテゴリの記事
- [正規表現]Quotationクォテーションの置き換え(2016.03.12)
- [Jedit X]Tab区切りテキストからテーブルを生成する(2011.01.12)
- [正規表現]#からはじまる行を削除(2011.01.11)
- [RegExp]文字間にスペースを入れる(正規表現)(2010.12.17)
- [Jeditx]特定の文字数毎に改行(2010.12.02)