有没有一种方法可以使用Excel中的“查找和替换”功能替换文本字符串中的第一个和最后一个条目?

时间:2019-08-28 17:23:54

标签: excel

我有一个字母序列,在我的情况下是基因的一部分。我想更改此文本字符串中的第一个和最后一个字母,但保持内部字符相同。

例如,如果我有序列:

  • ATCGAATCCATGACG

我想将第一个字母(在这种情况下,将A更改为START),并将最后一个字母G,更改为STOP,同时保持内部A和G相同。这可能与“查找和替换”功能有关,还是我必须编写脚本?

当我有几个序列时,这很容易做到,我是手工完成的。当我进入数百人时,可能会非常困难。

谢谢。

3 个答案:

答案 0 :(得分:1)

函数<div id="container"> <div class="beatiful-card"> <div class="images"><img class="mainImage" src="https://rukminim1.flixcart.com/image/832/832/jbs96kw0/carpet-rug/v/3/f/carpetblu-03-supreme-home-collective-original-imaewgneqxtsvgfr.jpeg?q=70"/></div> <div class="holderPart"> <h3 class="title">MyCode</h3> <p class="description">Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p> <svg viewBox="0 0 500 500" preserveAspectRatio="xMinYMin meet"> <path d="M0,100 C150,200 350,0 500,100 L500,00 L0,0 Z" style="stroke: none; fill:#fff;"></path> </svg> <div class="callToActionButton">Hi , Jeffreson<i class="zmdi zmdi-favorite"></i></div> </div> </div> </div>返回字母字符串中的字符数。 LEN(text)返回字符串的中间部分。 MID(text, start, num_chars)将不同的字符串组合在一起。我们可以结合使用这些来获得您想要的东西:

CONCATENATE(text1, text2, ...)

enter image description here

答案 1 :(得分:1)

您可以使用replace,并分别专注于左侧和右侧,然后进行合并,也可以使用=CONCATENATE("START", MID(A1,2,LEN(A1)-2), "STOP") / left将文本字符串添加到可用字符串中减去一个字符,例如:

right

enter image description here

我使用了="START"&LEFT(RIGHT(A1,LEN(A1)-1),LEN(A1)-2)&"STOP" / left,但是right也可以使用

答案 2 :(得分:0)

另一种选择:

=REPLACE(REPLACE(A1,LEN(A1),1,"STOP"),1,1,"START")

enter image description here

相关问题