General Replace Questions

sputnik

Member
Joined
Oct 11, 2005
Messages
10
Programming Experience
5-10
1. In the old VBScript, there was a compareMethod (binary or text, which with text, I could compare case) but I don't find anything like that in the new .Net Replace method. I know I can use the old way, but I'd like to use the new Replace method. I just need a choice of comparing case or not
Is there anything like this?

2. Let's say I have a long string, and I am using the Replace method - - it would be nice to get the count of instances replaced, and I'm sure that if I read line by line, I could actually get that count, but it would take to long.
Is there a way, using the Replace method, to get a count of how many actual replacements were made?
 
1. You'd have to use Regex.Replace instead of String.Replace.

2. No there isn't. If you follow my previous advice though, you could use the same Regex to get a match list and then get the length of that before calling Replace.
 
Back
Top