正则表达式 大写转小写
是否可以将正则表达式模式匹配转换为小写?
var pattern:RegExp;
var str:String = "HI guys";
pattern = /([A-Z]+)/g;
str = str.replace(pattern, thisShouldBeLowerCase);
输出应如下所示:“嗨,伙计们”
Is it possible to transform regexp pattern match to lowercase?
var pattern:RegExp;
var str:String = "HI guys";
pattern = /([A-Z]+)/g;
str = str.replace(pattern, thisShouldBeLowerCase);
Output should look like this: "hi guys"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以执行类似的操作,但将模式替换为您需要的模式:
< code>arguments 变量是引用函数参数的内部变量。希望有帮助,
兰斯
You can do something like this, but replace the pattern with exactly what you need:
That
arguments
variable is an internal variable referencing the function parameters. Hope that helps,Lance
小写
和大写
to lowercase
and to uppercase
在 ActionSctipn 3 中将所有大写英文字母更改为小写
Change all upper english letters to lower in ActionSctipn 3
不,使用正则表达式是不可能的。您只能将
A
替换为a
,将B
替换为b
,等等。不能一次全部替换。为什么不简单地使用
toLowerCase()
?
No, that is not possible using regex. You can only replace
A
witha
,B
withb
, etc. Not all at once.Why not simply use
toLowerCase()
?您可以使用函数作为 string.replace 的第二个参数,
在您的情况下您可以使用
此处阅读更多信息
Javascript:如何传递找到的字符串。替换值以发挥作用?
you can use a function as the second argument for string.replace
in your case you could use
read more about it here
Javascript: how to pass found string.replace value to function?
如果要将完整字符串转换为小写,请在 javascript 中使用
.toLowerCase()
或.toUpperCase()
。如果您想将字符串中的特定字母替换为小写字母,那么 Regex 会更好。
If you want to convert complete string to lowercase then use
.toLowerCase()
or.toUpperCase()
in javascript.If you want to replace a particular letter with lowercase in a String then
Regex
is better.