我有一些行需要更改。它们是蛋白质序列。如何将行的前4个字符复制到行的末尾,同时又将后4个字符复制到行的开头? 字符串是使它复杂化的变量,例如:
> X
LTGLGIGTGMAATIINAISVGLSAATILSLISGVASGGAWVLAGAKQALKEGGKKAGIAF
> Y
LVATGMAAGVAKTIVNAVSAGMDIATALSLFSGAFTAAGGIMALIKKYAQKKLWKQLIAA
此外,我如何排除开头带有'>'的行(这些是相应序列的名称)?
有人知道正则表达式可以使它工作吗?
我已经尝试过一些正则表达式解决方案,但是我对这种事情不太有经验,我可以找到结尾字符串,但无法替换它:
查找:
(...)$
替换:
^ $ 2 $ 1“
我想要实现的一个例子是:
> 1
ABCDEFGHIJKLMNOPQRSTUVWXYZ
成为:
> 1
WXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCD
谢谢
答案 0 :(得分:4)
答案 1 :(得分:3)
您可以在下面使用正则表达式。
var my_country = "United States"; // country which is going to auto selected
var url_country="<?=base_url()?>country.json";
var negara_list ="<option value=''></option>";
$.getJSON(url_country, function(data) {
$.each(data,function(key,val){
if(my_country == val)
{
negara_list += "<option value="+val+" selected>"+val+"</option>";
}
else
{
negara_list += "<option value="+val+">"+val+"</option>";
}
});
$(".negara").html(negara_list);
});
在https://regex101.com/r/W786uL/3上查看如何使用替换功能。
^(([A-Z]{4})([A-Z]*)([A-Z]{4}))$
^ asserts the position at the start of the line, so nothing can come before it.
( is the start of a capture group, this is group 1.
( is the start of a capture group, this is group 2. This group is inside group 1.
[A-Z]{4} means exactly 4 capital characters from A to Z.
) is the end of capture group 2.
( is the start of a capture group, this is group 3.
[A-Z]* matches capital characters from A to Z between zero and infinite times.
) is the end of capture group 3.
( is the start of a capture group, this is group 4.
[A-Z]{4} means exactly 4 capital characters from A to Z.
) is the end of capture group 4.
$ asserts the position at the end of the line, so nothing can come after it.
答案 2 :(得分:0)