一個通用正則庫

regex-util

github 地址: 傳送門

正則表達式可以用于匹配和替換,該項目搜集開發(fā)者日常開發(fā)任務(wù)需要用到的一些匹配、驗證的需求。

該項目會不斷收集,不斷優(yōu)化,歡迎issues!

安裝

$ npm install regex-util --save

使用

const regex-util = require('regex-util');

regex-util.isIDCard('440682199011133238')

API

Checker

  • isIDCard 身份證檢查

    /**
    * Check whether the content is IDCard
    * @param {string} content
    */
    isIDCard = function( content )
    
  • isPassword 檢查是否符合密碼強度 (密碼的強度必須是包含大小寫字母和數(shù)字的組合,不能使用特殊字符,長度在8-10之間) ,
    參數(shù)可以調(diào)整

    /**
    
  • Check whether the password meets the requirements

  • @param {string} content

  • @param {boolean} isGroup 是否開啟包含大小寫字母和數(shù)字的組合

  • @param {boolean} acceptSpecial 能否使用特殊字符

  • @param {int} starLength 最低長度

  • @param {int} endLength 最高長度
    */
    isPassword = function( content , isGroup , acceptSpecial , starLength , endLength)

  • isChinese 中文檢查

    /**
    * Check whether the content is Chinese
    * @param {string} content
    */
    isChinese = function( content )
    
  • isEmail 郵箱檢查

   /**
   * Check whether the content is Email
   * @param {string} content
   */
   isEmail = function( content )
    ```
* isMoney  金額檢查

/**

  • 檢查文本是否是金額,支持小數(shù)點
  • @param {string} content
    */
    isMoney = function( content )
```
  • isPhone 手機號檢查
   /**
   * Check whether the content is Phone
   * @param {string} content
   */
   isPhone = function( content )
    ```

###Matcher
* getPictures  獲取html中的所有圖片鏈接

/**

  • @param {string} html
    */
    getPictures = function( html )
```

License

MIT

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容