简体   繁体   中英

Adding exceptions to regular expressions (using android studio)

I'm new to regular expressions I'm doing a java project and I'm trying to specify a string of characters that only include alphabetic characters plus, some special characters such as ö , ä , å and ü .

How can I specify all these in regex? So far I have this but it does not work:

return s.matches("^[a-zA-Z]*$ && [öäå]");

update:

ok so with this expression return s.matches("^[\\\\p{L}\\\\p{Nd}]*$"); I get all characters including ö and Ä but not å and ü

You don't need to use the AND operator in regex expressions.

return s.matches("^[a-zA-Zöäåü]*$");

That should do the trick.

请尝试以下操作: "^([a-zA-Z]+|([öäå])+)[a-zA-Z]*$"

可以尝试这样的事情^[a-zA-Zöäå]*$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM