Sed regex between known word and unknown integer -
i can't quite regex need solve this, asking wizards help!
given:
locus node_96_length_17326_cov_8.76428_id_1>17327 bp dna linear locus node_97_length_17208_cov_6.56803_id_1>17208 bp dna linear locus node_98_length_17111_cov_6.60638_id_1>17111 bp dna linear locus node_99_length_17092_cov_6.7682_id_19717092 bp dna linear locus node_9_length_59921_cov_8.04963_id_1759921 bp dna linear
i need replace string between node
, sequence of numbers @ end of same string. character preceeding numbers (e.g. in line 1, 17327
) can appear >
or _
. need replace node
, including last >
or _
, or match until multi-digit integer of unknown length.
best i'd managed far was:
sed 's/\(node.*\)\(>|_\)/newstring/'
but know doesn't work.
just make painfully clear, desired output.
locus newstring 17327 bp dna linear locus newstring 17208 bp dna linear locus newstring 17111 bp dna linear locus newstring 19717092 bp dna linear locus newstring 1759921 bp dna linear
you don't need use group since not using back-references. can use:
sed 's/node[^[:blank:]]*[_>]/newstring /' file locus newstring 17327 bp dna linear locus newstring 17208 bp dna linear locus newstring 17111 bp dna linear locus newstring 19717092 bp dna linear locus newstring 1759921 bp dna linear
Comments
Post a Comment