简体   繁体   English

替换除某些字符外的所有非字母数字字符

[英]Replacing all non-alphanumeric characters except some characters

I want to replace all non-alphanumeric characters, but keep Æ, Ø, Å, æ, ø, å. 我要替换所有非字母数字字符,但保留Æ,Ø,Å,æ,ø,å。
Current code: 当前代码:

  replaceAll("\\P{Alnum}", "_")

Use explicit white list instead: 请使用明确的白名单:

replaceAll("[^a-zA-Z0-9ÆØÅæøå]","_")

Look at the similar question 看看类似的问题

以下对您有用吗?

 replaceAll("[^A-Za-z0-9ÆØÅæøå]", "_")

试试这个:

replaceAll("^[a-zA-ZÆØÅæøå]*$", "_");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用正则表达式删除$以外的所有非字母数字字符 - Regular expression to remove all non-alphanumeric characters except $ 用空字符串替换所有非字母数字字符 - Replacing all non-alphanumeric characters with empty strings 用空字符串替换所有非字母数字+标点字符 - Replacing all non-alphanumeric + punctuation characters with empty strings Java Regex - 删除除换行符以外的非字母数字字符 - Java Regex - Remove Non-Alphanumeric characters except line breaks 正则表达式要删除所有具有通用语言支持的非字母数字字符吗? - Regex to remove all non-Alphanumeric characters with universal language support? 通过忽略(不替换)非字母数字字符或查看第一个字母数字字符对字符串列表进行排序 - Sorting a list of strings by ignoring (not replacing) non-alphanumeric characters, or by looking at the first alphanumeric character 正则表达式匹配ASCII非字母数字字符 - Regex to match ASCII non-alphanumeric characters 如何删除任何非字母数字字符? - How to remove any non-alphanumeric characters? 如何从字符串中删除所有非字母数字字符(Java中的小数点除外) - How to remove all non-alphanumeric characters from a string expect decimal point in Java 删除所有非字母数字字符但允许多字词 - remove all non-alphanumeric characters but allow multi-word terms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM