Community discussion forum

Replace Function in vb.net

Tags: .net, vb.net India
  • 3 months ago

    Hi,

    I have a string say for eg:

    dim str as string="3-1/8"x13-1/2"x1'~ARCH~GLULAM~HEADER~DFIR~HEAD~SIMPLE~HEAD"

    I want to replace the word "HEAD" to "ABC"

    when i use the replace function of .net it correctly replaces HEAD to ABC which is correct and also it replaces HEADER AS ABCER..Which should not happen and is incorrect..How to replace only the word HEAD To ABC and Not HEADER

    Thanks in Advance.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 3 months ago

    Hi,

     You can use regular expressions to match HEAD and NOT HEADER

    Or

     if HEAD always appears at the end og the string you can do a replace on the end of the string

     

  • 3 months ago

    Faster way is byPassing: you replace HEADER with some temporary text, then HEAD with abc, and then replace temporary text back with header

Post a reply

Enter your message below

Sign in or Join us (it's free).