regexp-cjk-plugin-extra
TypeScript icon, indicating that this package has built-in type declarations

1.0.43 • Public • Published

README

a regexp-cjk plugin demo for regexp-cjk ( 自動配對 五十音的清/濁音  ,  半形/全形 ,  deburr )

各參數效果請看這裡 demo.test.ts

install

npm install regexp-cjk-plugin-extra cjk-conv
yarn add regexp-cjk-plugin-extra cjk-conv
yarn-tool add regexp-cjk-plugin-extra cjk-conv

usage

index.d.ts

export interface IZhRegExpPluginOptionsCore {
    /**
     * 平假名片假名的 清濁音
     */
    autoVoice?: boolean;
    /**
     * 自動配對 半形 全形
     */
    autoFullHaif?: boolean;
    /**
     * 配對本地化字元
     */
    autoLocale?: boolean;
    /**
     * deburr('déjà vu') // => 'deja vu'
     *
     * Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing combining diacritical marks.
     */
    autoDeburr?: boolean;
    /**
     * if return null | undefined then will skip current node
     */
    callback?(raw: string): string | string[];
}
export declare type IZhRegExpPluginOptions = IZhRegExpPluginOptionsCore & {
    /**
     * 緩存
     */
    cacheMap?: boolean | ICacheMap;
};
import zhRegExp, { IOptions } from 'regexp-cjk';
import createZhRegExpPlugin, { IZhRegExpPluginOptions } from 'regexp-cjk-plugin-extra';

let options: IZhRegExpPluginOptions = {
    autoDeburr: true,
}

let re = new zhRegExp(/déjà vu/ui, {
    on: [
        createZhRegExpPlugin(options)
    ],
});

let word = `deja vu`;

console.log(re, word, re.test(word))

Dependencies (5)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i regexp-cjk-plugin-extra

    Weekly Downloads

    67

    Version

    1.0.43

    License

    ISC

    Unpacked Size

    34.3 kB

    Total Files

    6

    Last publish

    Collaborators

    • bluelovers