Sunday, June 28, 2009

Regular Expressions :Regex.Replace()

I now have a coding blog, yay!

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