javascript - encodeURIComponent() 小写
问题描述
在 JavaScript 中,我想使用encodeURIComponent()
,但输出是大写的。
console.log(encodeURIComponent("[Abcd123]"));
//returns %5BAbcd123%5D
我想要一个小写的结果,比如
%5bAbcd123%5d
可能吗?
解决方案
您可以使用正则表达式将后面的两个字符转换%
为小写。
console.log(encodeURIComponent("[Abcd123]").replace(/%../g, match => match.toLowerCase()));
推荐阅读
- excel - EXCEL:如何增加工作表但使用自动填充保持单元格引用相同?
- javascript - 在 Const 中反应 userParams
- excel - 列中的依赖下拉列表
- forms - 将查询参数值添加到 TYPO3 表单
- salesforce - Apex 类 - System.NullPointerException:尝试取消引用空对象
- java - 如果我不需要在泛型类中指定类型,我应该使用
- python - 具有与信息增益不同的分割标准的决策树
- python - 如何使用 Plotly 绘制循环的局部变量
- python - 自定义 Django 模型管理器在尝试使用时出错
- wordpress - 使用 REST API 将标签添加到 wordpress 帖子