String.replaceAll is considerably slower than doing the job yourself

While using regular expressions imparts some performance impact, it should not be as terrible. Note that using String.replaceAll() will compile the regular expression each time you call it. You can avoid that by explicitly using a Pattern object: Pattern p = Pattern.compile(“[,. ]+”); // repeat only the following part: String output = p.matcher(input).replaceAll(“”); Note also … Read more

Java string replace and the NUL (NULL, ASCII 0) character?

Does replacing a character in a String with a null character even work in Java? I know that ‘\0’ will terminate a c-string. That depends on how you define what is working. Does it replace all occurrences of the target character with ‘\0’? Absolutely! String s = “food”.replace(‘o’, ‘\0’); System.out.println(s.indexOf(‘\0’)); // “1” System.out.println(s.indexOf(‘d’)); // “3” … Read more

Is it possible to replace to uppercase in Visual Studio?

You can solve this by using Visual Studio temporary macros. This is a very powerful, flexible feature which I use all the time for performing repetitive code manipulations. I’m assuming you’re using the C# default key bindings here. Press CTRL+SHIFT+F to bring up the find in files dialogue. Click use “Regular expressions” Set “Find what:” … Read more