Last active
April 10, 2023 11:05
-
-
Save yapcheahshen/e522c20abb42df096422d7c7d2a8c7fc to your computer and use it in GitHub Desktop.
將Emeditor 選取區的中文數字轉為number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* to install, EmEditor Macro menu, customize, add , select cnumber.jsee */ | |
if (!document.selection.IsEmpty) { | |
var lines=document.selection.Text.split(/\r?\n/); | |
var out=[]; | |
for (var line=0;line<lines.length;line++) { | |
var val=parseInt(lines[line] | |
.replace(/百([二三四五六七八九])十/,'$1十') | |
.replace(/百十$/,'10') | |
.replace(/百十/,'1') | |
.replace(/百$/,'00') | |
.replace(/百/,'0') | |
.replace(/一/g,'1') | |
.replace(/二/g,'2') | |
.replace(/三/g,'3') | |
.replace(/四/g,'4') | |
.replace(/五/g,'5') | |
.replace(/六/g,'6') | |
.replace(/七/g,'7') | |
.replace(/八/g,'8') | |
.replace(/九/g,'9') | |
.replace(/^十$/,'10') | |
.replace(/^十/,'1') | |
.replace(/十$/,'0') | |
.replace(/十/,'') | |
.replace(/[○〇零]/g,'0')); | |
out.push( val.toString() ); | |
} | |
document.selection.Text=out.join("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demovideo