Skip to content

I want to insert some symbols in the middle of the word

Pavi S

Asked Mar 21, 2012, 2:40 AM EDT2 answers
Share
LinkedInX
I want to insert some symbols in the middle of the word (particular place)

Eg:
PostFix(anyword)
i want to insert the hypen to  Post-Fix 


secondword to second-word(we already know that second and word two separate word)


please just me to solve this prob.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Gohil Jayendrasinh
    0

    hi

    It's simple

    Code
      string string1 = "secondword";
    Code
      string string2 = "second";
    Code
      string final = stringseparator(string1, string2,"-");
    C#
     private static string stringseparator(string string1, string string2, string separator)
    Code
            {
    Code
                string string1_part1 = string1.Substring(0, string1.IndexOf(string2));
    Code
                string string1_part2 = string1.Substring(string1.IndexOf(string2) + string2.Length, string1.Length - (string1.IndexOf(string2) + string2.Length));
    Code
    Code
                string1 = string2 + separator + string1_part2;
    Code
                return string1;
    Code
            }

    if it's helpful to you then please check Accepted Asnwers

    Thanks

    0
  • 0

    thanks but i want like this,but the belw code not working,

    Code
    Mword.Selection.Text=sometext;
    torepl='-';
    wdl= Len(some)
    
    If Len(Mword.Selection.Text) > 1 Then
    
     Mword.Selection.MoveLeft(Unit:=Word.WdUnits.wdCharacter, Count:=1)
    
     Mword.Selection.MoveLeft(Word.WdUnits.wdCharacter, CInt(wdl))
     Mword.Selection.InsertAfter(torepl)
    
    End If

    my ouput
    -----------

    some-text

    0