c# - How to replace > 1 tokens on a string? -
i have list of tokens
[@date] [@time] [@filename] ... etc
that dispersed on large file. can parse file , replace them regex.replace
when there's 1 token on line. problem arises when there's 2 tokens on 1 line
example:
[@date] [@time]
what thought doing using string.split
" " delimiter
, , iterate through result checking if there tokens.
but see 2 problems approach, file rather large , impact performance. second problem file outputted sql
file , i'd retain white space looks.
is there more elegant solution problem? or case of premature optimization?
one thing can instead of replacing patterns line line, replace them in whole file:
string filecontent = file.readalltext(path); filecontent = regex.replace(filecontent, pattern1, replacement1); ... filecontent = regex.replace(filecontent, patternn, replacementn);
Comments
Post a Comment