【发布时间】:2020-11-17 03:53:41
【问题描述】:
如何编写一个正则表达式,它只将由任何字符组成的标准字符串转换为只以_、-、$ 或非重音字母开头,而字符串的其余部分只能有那些字符或非重音字母?
我可以使用preg_replace("/[^a-zA-Z]/", "", $value) 获取所有非数字,但这不是我需要的。
我想做的是取一个字符串,最初可能是取这个字符串
4_The quick brown fox jumps o8ver the lazy dog and the slow white dog fox jumps over the unlazy fox. 转成_Thequickbrownfoxjumpsoverthelazydogandtheslowwhitedogfoxjumpsovertheunlazyfox
【问题讨论】:
-
ok @anubhava 我有一个我所做的样本
-
问题不清楚。示例会很有帮助。
-
@rgbflawed 我有一个例子
-
喜欢这个?
(?:^[^_$a-zA-Z-]+|[^$\w-]+)regex101.com/r/jQCqch/1