Removing strings

  • Thread starter Thread starter Patrick.O.Ige
  • Start date Start date
P

Patrick.O.Ige

I have a file below
16_vir24CE.log
How can i remove 16_ or 123_
I want to have "vir24CE.log" as my output file
 
If the underscore is always the separator, the simplest method would be to
get the IndexOf("_") and the a substring based on that value.

something like

string newFilename = oldName.SubString(oldName.IndexOf("_") +1);

otherwise if your pattern is more complicated, you'll need to use a regular
expression.

Karl
 
Thx Karl i ended up using Regex like so
Dim FN As String = myReader.GetString(1)
Dim exp As New Regex("^\d+_")
FN = exp.Replace(FN, "")
But thx for the snippet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top