I have a text in this format:
term: 156:59 datainput
I want to remove the ":" between the number and then replace it with something else so the text can become:
term: 156-59 datainput
How can I do this in VB.NET?
I have a text in this format:
term: 156:59 datainput
I want to remove the ":" between the number and then replace it with something else so the text can become:
term: 156-59 datainput
How can I do this in VB.NET?
Assuming you have read the data in to a string, take a look at the string.replace function.
Yes, I know this is a little clumsy, but it should work (assuming your data is in exactly the format you specify):
input[input.IndexOf(":", input.IndexOf(":")+1)] = "#"
Of course, if you want a more general case to find NUMBER:NUMBER and replace it with NUMBER#NUMBER, I'd recommend using a regular expression, like this:
var re = new Regex(@"(\d+):(\d+)");
re.Replace(input, "$1#$2");
In VB.NET (credit Jonathan):
Dim text As String = "term: 156:59 datainput"
Dim fixedText As String = Regex.Replace(text, "(\d+):(\d+)", "$1-$2")
nb: removed last two lines as suggested.