Today I learned how to match and replace at the same time in a Regex:
'remove leading = if it exists
lines(index) = Regex.Replace(lines(index), "(?\s*)=(?.+)", "${space}${therest}")
This makes use of named captures to remove a leading =, preserving opening whitespace.
No comments:
Post a Comment