How to use regex non capturing group for string replace in java
Why not use look-ahead / look-behind instead?
They are non-capturing and would work easily here:
str = str
.replaceAll(
"(?<=\\[assembly: AssemblyVersion\\(\"\\d\\.\\d\\.).*(?=\"\\)\\])",
"4.0"
);