简体   繁体   English

如何在Excel中y个字符后替换x的第一个实例?

[英]How to replace first instance of x after y amount of characters in Excel?

I would like to use a formula to replace the first instance of a character, starting the search after a specific amount of characters from the right (including spaces). 我想使用一个公式来替换字符的第一个实例,然后从右边的特定数量的字符(包括空格)开始搜索。 eg in the sentence: 例如在句子中:

  One two three four Five six seven eight nine.

I would like to replace the first instance of a space (" ") with an underscore, starting the search after 17 characters (after "u" in the word "four") so the formula returns: 我想用下划线替换空格(“”)的第一个实例,在17个字符之后开始搜索(在单词“ four”中的“ u”之后),因此公式返回:

  One two three four_Five Six seven eight nine.

Please help! 请帮忙!

您可以使用REPLACE

=REPLACE(A1,FIND(" ",A1,17),1,"_")

What about below formula. 下面的公式呢? Try it... 试试吧...

=LEFT(A1,SEARCH(" ",A1,17)-1) & "_" & MID(A1,SEARCH(" ",A1,17),LEN(A1)-SEARCH(" ",A1,17)+1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM