How can I use excel function (LEFT/RIGHT/MID) to extract string which sorrounded by same symbol?

前端 未结 4 493
旧时难觅i
旧时难觅i 2021-01-17 02:13

My string is like; eg: A2 column : This is a test string.

Where I want to extract word \'is\'. I know I have to use MID function wi

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 02:38

    If you make all of the spaces the same width as the entire original string you can easily pick out the second word with MID and TRIM it back to its original.

    'first word
    =trim(left(substitute(a2, " ", rept(" ", len(a2))), len(a2)))
    'second word
    =trim(mid(substitute(a2, " ", rept(" ", len(a2))), len(a2)*1, len(a2)))
    'third word
    =trim(mid(substitute(a2, " ", rept(" ", len(a2))), len(a2)*2, len(a2)))
    'last word
    =trim(right(substitute(a2, " ", rept(" ", len(a2))), len(a2)))
    

    The len(a2)*1 (starting point of MID) is the dimension that determines which word is extracted.

提交回复
热议问题