perl - Find and replace a string in Perl
问题描述
I have the following command line:
perl -i -pe 's/_GSV*//g' file.fasta
My goal is change some sequences that have the following pattern:
GSVIVG01006342001_GSVIVT01006342001
I want to find all sequences that starts with _GSV and finish with anything (that`s why I put the '*') and substitute for nothing.
When I run my command it just recognize the _GSV and return to me that:
GSVIVG01006342001IVT01006342001
and I want that:
GSVIVG01006342001
Can anybody tell me what's wrong with my command line?
解决方案
before the *, include a dot that means any character
perl -i -pe 's/_GSV.*//g' file.fasta
You can also include the symbol $ to ensure you arrive until the end of the string
perl -i -pe 's/_GSV.*$//g' file.fasta
推荐阅读
- python-3.x - Python 熊猫 - 处理
- wordpress - 通过 IP 地址访问时,Wordpress 网站重定向到 localhost
- linux - 如何获取某个linux命令的所有可能值?
- mysql - MySQL连接两个表并添加额外的列
- r - R table1 包:指定字体大小和列宽?
- apache-spark - 将所有列从 StringType 转换为 DoubleType
- clickhouse - Clickhouse 结果有时显示空行
- mongodb - 是否可以使用聚合管道进行 $setOnInsert ?
- ios - 如何设置 SwiftUI ScrollView 的内容偏移量
- excel - 行展开/折叠时自动展开/折叠列