Anzure
Anzure

Reputation: 994

Replacing all non-alphanumeric characters except some characters

I want to replace all non-alphanumeric characters, but keep Æ, Ø, Å, æ, ø, å.
Current code:

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

Upvotes: 1

Views: 733

Answers (3)

void
void

Reputation: 7890

try this one :

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

Upvotes: 0

MaxZoom
MaxZoom

Reputation: 7763

Does below work for ya?

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

Upvotes: 0

Nikita Astrakhantsev
Nikita Astrakhantsev

Reputation: 4749

Use explicit white list instead:

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

Look at the similar question

Upvotes: 3

Related Questions