1 Star 0 Fork 0

longfeng / percentage-regex

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

validator

简介

本demo是基于openHarmony系统下使用三方js库percentage-regex,percentage-regex是百分比验证的库。

下载安装

ohpm install percentage-regex

使用说明

import percentageRegex from 'percentage-regex';

let result:boolean = percentageRegex({exact: true}).test("19%")
['10%'].toString() = 'foo 10% bar'.match(percentageRegex({exact: false})).toString()

接口说明

percentage-regex

接口 描述
percentageRegex(options) 返回匹配百分比值的正则表达式。
options.exact 类型:boolean ,默认值:false(匹配字符串中的任何百分比) ,只匹配一个精确的字符串。与“RegExp#test”一起检查某个字符串是否为百分比很有用。

单元测试用例详情

约束与限制

在下述版本验证通过:

DevEco Studio: 3.1 Beta2(3.1.0.400), SDK: API9 Release(3.2.11.9)

贡献代码

使用过程中发现任何问题都可以提Issue 给我们,当然,我们也非常欢迎你给我们提PR

开源协议

本项目基于 MIT License,请自由地享受和参与开源。

The MIT License (MIT) Copyright (c) Arthur Verschaeve <contact@arthurverschaeve.be> (arthurverschaeve.be) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Regular expression to match percentage values 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/longfeng20/percentage-regex.git
git@gitee.com:longfeng20/percentage-regex.git
longfeng20
percentage-regex
percentage-regex
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891