I have a problem with a list of strings where I want to change the first integer occurrence in each entry. The lines all look like this:
" 1ICE MW 1 0.138 0.181 0.348"
I am interested in changing the integer after the MW, namely adding 3 to it, but leaving the white spaces intact, like this:
" 1ICE MW 4 0.138 0.181 0.348"
Because I want to leave the white spaces intact, I cannot simply Stringsplit
, and because not every entry looks the same (the number before ICE increases, and the amount of white spaces then can change) I cannot just simply replace the "1" with "4". E.g. other entries could look like
" 128ICE MW 509 0.916 0.921 1.697"
So they would have a different amount of whitespace before the integer I want to change and at the start. Is there a way to do this with some kind of pattern recognition?