• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript replaceall类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中replaceall的典型用法代码示例。如果您正苦于以下问题:TypeScript replaceall类的具体用法?TypeScript replaceall怎么用?TypeScript replaceall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了replaceall类的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;
}
开发者ID:pierophp,项目名称:pinyin,代码行数:9,代码来源:remove.spaces.ts


示例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();
    });
开发者ID:pierophp,项目名称:pinyin,代码行数:9,代码来源:separate.words.ts


示例3: replaceall

 replaceIdeogramsToSpace.forEach(item => {
   audioTitleWithoutSpaces = replaceall(
     item,
     '',
     audioTitleWithoutSpaces,
   );
 });
开发者ID:pierophp,项目名称:pinyin,代码行数:7,代码来源:audio.parser.ts


示例4: async

    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,
        });
      });
    });
开发者ID:pierophp,项目名称:pinyin,代码行数:26,代码来源:cjk.repository.ts


示例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, {});
 }
开发者ID:pierophp,项目名称:pinyin,代码行数:9,代码来源:file.manager.ts


示例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);
  }
开发者ID:pierophp,项目名称:pinyin,代码行数:41,代码来源:with.pdf.parser.ts


示例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;
}
开发者ID:pierophp,项目名称:pinyin,代码行数:21,代码来源:segment.text.ts


示例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');
//.........这里部分代码省略.........
开发者ID:pierophp,项目名称:pinyin,代码行数:101,代码来源:ruby.parser.ts



注:本文中的replaceall类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript request类代码示例发布时间:2022-05-28
下一篇:
TypeScript remark类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap