dimanche 3 mai 2015

How to replaceAll "" with " " without touching a specific number?

This may look like a duplicate question but I really couldn't find an answer in those. After searching I learnt about regex and matcher but I couldn't come up with a solution. If you could help me I would really appreciate it.

In Java I want to replaceAll "" with " " in a string but only number 10 shouldn't be touched. So I don't want 10 to be like 1 0

Here is a String: String x = "123456789"

If I use this: x.replaceAll(".(?=.)", "$0 ")

I get: "1 2 3 4 5 6 7 8 9"

But if string was: x = "12345678910" How could I get: "1 2 3 4 5 6 7 8 9 10" and it could be like: x = {123104} And once again I need {1 2 3 10 4}

Thank you for checking...

Aucun commentaire:

Enregistrer un commentaire