Editing
Regular expression
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 取代換行符號為逗號 === 將Email清單,轉成Email軟體可以使用的寄信名單 <pre> 原 aaa@email.com bbb@email.com ccc@email.com 改成 aaa@email.com,bbb@email.com,ccc@email.com </pre> ==== 方案1: Sublime Text, EmEditor ==== 語法適用 [http://www.sublimetext.com/ Sublime Text], [http://www.emeditor.com/ EmEditor]軟體 (以下為 EmEditor 的操作說明) # Menu: Search -> Replace # click "Use Regular Expression" ## Find: {{kbd | key = <nowiki>\n</nowiki>}} ([[Return symbol | 換行符號]] 。{{Win}} 作業系統的換行符號是 {{kbd | key = <nowiki>\r\n</nowiki>}}、{{Mac}} 作業系統的換行符號是 {{kbd | key = <nowiki>\n</nowiki>}},取兩者共有的符號。如果使用 {{Linux}} 作業系統的換行符號是 {{kbd | key = <nowiki>\r</nowiki>}}。 ) ## Replace with: {{kbd | key = <nowiki>, </nowiki>}} # click "Replace all" <div style="float: left; width: 100%; position: relative; display: block; clear: left;"> <div style="width: 46%; float: left; margin:0 auto; position: relative; display: block; "> ===== 將每行的文字,移除換行,並且都加上逗號分隔 ===== <pre> // before Elmo Emie Granny Bird // after Elmo, Emie, Granny Bird </pre> 方法: 使用 [http://www.sublimetext.com/ Sublime Text] 或 [https://zh-tw.emeditor.com/ EmEditor]。 * Find what: {{kbd | key = <nowiki>\n</nowiki>}} * Replace with: {{kbd | key = <nowiki>, </nowiki>}} 此例是將每行的文字,都加上逗號+空格分隔 (如果要用別的符號分隔,例如頓號分隔,則是 Replace with: {{kbd | key = <nowiki>、</nowiki>}}) </div> <div style="width: 46%; float: left; margin:0 auto; position: absolute; display: block; left: 54%; top: 0;"> ===== 將逗號分隔的文字,還原成逐行顯示,並且移除分隔符號 (,) ===== <pre> // before Elmo, Emie, Granny Bird // after Elmo Emie Granny Bird </pre> 方法: 使用 [http://www.sublimetext.com/ Sublime Text] 或 [https://zh-tw.emeditor.com/ EmEditor]。{{exclaim}} 輸出結果的每行前面可能會有空白 * Find what: {{kbd | key = <nowiki>([^,]+),</nowiki>}} * Replace with: {{kbd | key = <nowiki>\1\n</nowiki>}} </div> </div> <div style="clear:both;"> </div> ==== 方案2: Notepad++ ==== 使用[http://notepad-plus-plus.org/ Notepad++]軟體 # 選單: 尋找 -> 取代 # 搜尋模式: 勾選「增強模式」 (不是勾選「用類型表式」) ## 尋找目標: {{kbd | key = <nowiki>\n</nowiki>}} (換行符號) ## 取代成: {{kbd | key = <nowiki>, </nowiki>}} # 勾選全部取代 相關資料: [http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Replacing_Newlines How To Replace Line Ends, thus changing the line layout] last visited: 2010-01-27 ==== 方案3: Microsoft Word ==== 使用Microsoft Word 2002軟體 # 選單: 編輯 -> 取代 # 勾選增強模式 ## 尋找目標: {{kbd | key = <nowiki>^p</nowiki>}} (段落標記) ## 取代為: {{kbd | key = <nowiki>, </nowiki>}} # 勾選全部取代 ==== 方案4: Sed command for linux ==== {{kbd | key=<nowiki>sed 's/要被取代的字串/新的字串/g' old.filename > new.filename</nowiki>}}<ref>[http://linux.vbird.org/linux_basic/0330regularex.php#sed_replace 鳥哥的 Linux 私房菜 -- 正規表示法 (regular expression, RE) 與文件格式化處理]</ref> (1)要被取代的字串: :a;N;$!ba;s/\n (2)新的字串: ; {{kbd | key=<nowiki>sed ':a;N;$!ba;s/\n/; /g' old.filename > new.filename</nowiki>}} <ref>參考 [http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n unix - sed: How can I replace a newline? ]</ref> ==== 方案5: 使用支援十六進位編輯 (HEX) 的編輯軟體 ==== 使用支援十六進位編輯 (HEX) 的編輯軟體,例如: [https://itunes.apple.com/tw/app/ihex-hex-editor/id909566003?mt=12 iHex - Hex Editor] for {{Mac}} # 選單 Edit -> Find # Find: {{kbd | key=<nowiki>0A</nowiki>}} 換行符號 # Replace: {{kbd | key=<nowiki>2c 20</nowiki>}} 其中 2c 是逗號, 20 是空白 # 儲存檔案 相關資料 * [https://www.hexdictionary.com/ Hex Dictionary | Convert Hex / Hexadecimal Numbers to Binary and Decimal]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information