本文整理汇总了TypeScript中replaceall.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript replaceall.default方法的具体用法?TypeScript replaceall.default怎么用?TypeScript replaceall.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类replaceall
的用法示例。
在下文中一共展示了replaceall.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: removeSpaces
export function removeSpaces(str: string): string {
str = str.replace(/[\u200B-\u200D\uFEFF]/g, ''); // replace zero width space to space
str = replaceall(String.fromCharCode(160), '', str); // Convert NO-BREAK SPACE to SPACE
str = replaceall(String.fromCharCode(8201), '', str); // Convert THIN SPACE to SPACE
str = replaceall(String.fromCharCode(8203), '', str); // Zero Width Space
str = replaceall(' ', '', str); // Zero Width Space
return str;
}
示例2: replaceall
.filter(item => {
item = replaceall(String.fromCharCode(160), '', item); // Convert NO-BREAK SPACE to SPACE
item = replaceall(String.fromCharCode(8201), '', item); // Convert THIN SPACE to SPACE
item = replaceall(String.fromCharCode(8203), '', item); // Zero Width Space
item = replaceall(String.fromCharCode(8206), '', item); // Left-To-Right Mark
item = replaceall(String.fromCharCode(8234), '', item); // Left-To-Right Embedding
return item.trim();
});
示例3: replaceall
replaceIdeogramsToSpace.forEach(item => {
audioTitleWithoutSpaces = replaceall(
item,
'',
audioTitleWithoutSpaces,
);
});
示例4: knex
await bluebird.mapSeries(items, async (item: any) => {
let ideograms = ideogramsConverter.convertUtf16ToIdeograms(item.ideogram);
ideograms = replaceall('%', '', ideograms);
if (!ideograms) {
return;
}
i += 1;
profiler(`${i} - ${ideograms}`);
const phrases = await PhraseRepository.findByLanguageAndRlike(
language,
ideograms,
);
if (phrases.length === 0) {
return;
}
await bluebird.mapSeries(phrases, async (phrase: any) => {
await knex('cjk_has_phrase').insert({
cjk_id: item.id,
phrase_id: phrase.id,
});
});
});
示例5: saveFile
public async saveFile(
userId: number,
filename: string,
content: string,
): Promise<any> {
const adapter = this.getAdapter();
filename = replaceall('../', '', filename);
await adapter.write(`files/${userId}/${filename}`, content, {});
}
示例6: parse
public async parse(
item: ParseItemInterface,
pdfParsedObjectPromise: Promise<any>,
): Promise<BlockInterface[] | undefined> {
const text: string = item.chinese.text || '';
const textSimplified: string = item.simplified
? item.simplified.text || ''
: '';
/**
* If simplified and traditional paragraph does'n have the same size
* don't use PDF for traditional
*/
if (textSimplified) {
const textSimplifiedVerification = replaceall(' ', '', textSimplified);
const textVerification = replaceall(' ', '', text);
if (textSimplifiedVerification.length !== textVerification.length) {
return;
}
}
const line = textSimplified ? textSimplified : text;
const parsedResult = await this.pdfPinyin(
pdfParsedObjectPromise!,
[line],
item,
);
if (!parsedResult) {
return;
}
if (!textSimplified) {
return parsedResult;
}
return restoreTraditional(text, parsedResult);
}
示例7: segmentText
export function segmentText(line: string): string {
let verifyText = line;
replaceIdeogramsToSpace.forEach(item => {
verifyText = replaceall(`${item} `, item, verifyText);
});
verifyText = verifyText.replace(/(\d+)/, '');
verifyText = verifyText.trim();
if (!verifyText) {
verifyText = '';
}
const minimunWords = replaceall(' ', '', verifyText).length / 2.5;
if (verifyText.split(' ').length < minimunWords) {
return separateWords(line).join(' ');
}
return line;
}
示例8: parse
public async parse(
item: ParseItemInterface,
parseSimplified: boolean,
): Promise<BlockInterface[] | undefined> {
let text = item.chinese.text!;
if (parseSimplified) {
text = item.simplified!.text!;
}
if (parseSimplified) {
let traditionalToCompare = item.chinese.text!;
let simplifiedToCompare = item.simplified!.text!;
traditionalToCompare = striptags(traditionalToCompare).replace(/ /g, '');
simplifiedToCompare = striptags(
simplifiedToCompare
.replace(/<rt>(.*?)<\/rt>/g, '')
.replace(/<ruby>/g, '')
.replace(/<\/ruby>/g, ''),
).replace(/ /g, '');
if (traditionalToCompare.length !== simplifiedToCompare.length) {
console.info('RUBY - SIMPLIFIED AND TRADITIONAL NOT EQUALS');
console.info('TRADITIONAL', traditionalToCompare);
console.info('SIMPLIFIED', simplifiedToCompare);
return;
}
}
const blocks = text.split(/<ruby>|<\/ruby>/).filter(item => item.trim());
let items: any[] = [];
for (let block of blocks) {
const rtMatch = block.match(/<rt>(.*)<\/rt>/);
let pinyin = [];
if (rtMatch) {
block = replaceall(rtMatch[0], '', block);
pinyin = separatePinyinInSyllables(striptags(rtMatch[1]));
}
block = removeSpaces(striptags(block));
if (!block) {
continue;
}
items.push({
c: block.split(''),
p: pinyin,
});
}
items = backHtmlTags(items, text);
items = fillBoldItalic(text, items);
if (items.length > 0) {
items[0].line = {
type: item.chinese.type,
pinyinSpaced: 1,
pinyin_source: 'ruby',
};
}
let bible;
let response: any[] = [];
for (let item of items) {
item.c = item.c.join('').trim();
item.p = item.p.join(String.fromCharCode(160));
if (!item.c) {
continue;
}
if (item.isBold) {
item.isBold = 1;
}
if (item.isItalic) {
item.isItalic = 1;
}
// @ts-ignore
const tempBible = parseBible(item.tagsStart);
if (tempBible) {
bible = tempBible;
}
if (bible && !isChinese(item.c, true)) {
item.b = bible;
bible = null;
}
let indexOfFootnote = -1;
if (item.tagsStart) {
indexOfFootnote = item.tagsStart.indexOf('<footnote');
//.........这里部分代码省略.........