我有一个匹配所有ascii字符的正则表达式:
@ApiImplicitParams({
@ApiImplicitParam(name = "page", dataType = "integer", paramType = "query",
value = "Results page you want to retrieve (0..N)"),
@ApiImplicitParam(name = "size", dataType = "integer", paramType = "query",
value = "Number of records per page."),
@ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query",
value = "Sorting criteria in the format: property(,asc|desc). " +
"Default sort order is ascending. " +
"Multiple sort criteria are supported.")
})
现在,我需要从此范围中排除以下字符:/^[\x00-\x7F]*$/
,'
。我该怎么做?
答案 0 :(得分:2)
答案 1 :(得分:2)
您可以通过
排除某个范围内的字符/^(?![\.])[\x00-\x7F]*$/
以(?![\.])
作为前缀,从正则表达式匹配中排除.
。
或在您的方案中
/^(?!['"])[\x00-\x7F]*$/
修改:
将正则表达式包装在大括号中以多次匹配
/^((?!['"])[\x00-\x7F])*$/
答案 2 :(得分:1)
IMO是迄今为止最简单的解决方案:
/^[\x00-\x21\x23-\x26\x28-\x7F]*$/