[英]Regex that will only allow alphanumeric characters and underscore and specific placeholder inside curly braces
我想要一個只允許字母數字字符和下划線以及花括號內的特定占位符的正則表達式。
有效示例:
test{placeholder}
test_{placeholder}
test_123_{placeholder}
test
test_123
test123
{placeholder}_test
test{placeholder}test
And any combination of above.
這就是我想出的:
[^-A-Za-z0-9_]|^\{placeholder\}
我的理解方式是:
[^-A-Za-z0-9_]
- 不允許使用除 az 0-9 和下划線之外的任何其他字符。
|^\\{placeholder\\}
- 或者任何沒有說 {placeholder} 的東西
但它不起作用,我不知道為什么。
這是演示
請幫忙。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.