ChangeGrepX(
"\\d+",
function(s){
s=s.replace(/[00]/g,"〇");
s=s.replace(/[11]/g,"一");
s=s.replace(/[22]/g,"二");
s=s.replace(/[33]/g,"三");
s=s.replace(/[44]/g,"四");
s=s.replace(/[55]/g,"五");
s=s.replace(/[66]/g,"六");
s=s.replace(/[77]/g,"七");
s=s.replace(/[88]/g,"八");
s=s.replace(/[99]/g,"九");
s=s.replace(/([〇一二三四五六七八九]+)([〇一二三四五六七八九]{20})/,"$1垓$2");
s=s.replace(/([〇一二三四五六七八九]+)([〇一二三四五六七八九]{16})/,"$1京$2");
s=s.replace(/([〇一二三四五六七八九]+)([〇一二三四五六七八九]{12})/,"$1兆$2");
s=s.replace(/([〇一二三四五六七八九]+)([〇一二三四五六七八九]{8})/,"$1億$2");
s=s.replace(/([〇一二三四五六七八九]+)([〇一二三四五六七八九]{4})/,"$1万$2");
s=s.replace(/([〇一二三四五六七八九])([〇一二三四五六七八九]{3})/g,"$1千$2");
s=s.replace(/([〇一二三四五六七八九])([〇一二三四五六七八九]{2})/g,"$1百$2");
s=s.replace(/([〇一二三四五六七八九])([〇一二三四五六七八九])/g,"$1十$2");
s=s.replace(/一([千百十])/g,"$1");//
s=s.replace(/([千百十])〇([垓京兆億万])/g,"$1$2");
s=s.replace(/〇[垓京兆億万千百十]/g,"");
s=s.replace(/〇/g,"");
return s;
}
)
function ChangeGrepX(regstr,func) {
if (app.scriptPreferences.version>=7) {
app.doScript(ChangeGrepXMain,ScriptLanguage.JAVASCRIPT,[],UndoModes.ENTIRE_SCRIPT);
} else {
ChangeGrepXMain();
}
function ChangeGrepXMain(){
var SelTexts=getTextObjs(app.activeDocument.selection);
app.findGrepPreferences=NothingEnum.nothing;
app.findGrepPreferences.findWhat =regstr;
for (var i=0;i<SelTexts.length;i++){
if (SelTexts[i].contents=="") continue;
var foundTexts=SelTexts[i].findGrep();
for (var j=foundTexts.length-1;j>=0;j--){
foundTexts[j].contents=func(foundTexts[j].contents);
}
}
function getTextObjs(Objs) {
var TextObjs=[];
for (var n=0;n<Objs.length;n++){
if (Objs[n].constructor.name=="Table") {
TextObjs=TextObjs.concat(Objs[n].cells.everyItem().texts[0].getElements());
} else if (Objs[n].hasOwnProperty("texts")) {
TextObjs=TextObjs.concat(Objs[n].texts.everyItem().getElements());
} else if (Objs[n].constructor.name=="Group") {
TextObjs=TextObjs.concat(getTextObjs(Objs[n].pageItems.everyItem().getElements()));
}
}
return TextObjs;
}
}
}
プロフィール
最近の記事