I have the following string:
%pre%It is a format %code% and is wrong because after the time there is %code% . To catch this snippet I used %code% :
%pre%How can I remove only the ending considering that I have many occurrences?
I have the following string:
%pre%It is a format %code% and is wrong because after the time there is %code% . To catch this snippet I used %code% :
%pre%How can I remove only the ending considering that I have many occurrences?
To capture the microsecond you can use the following regex %code% it says to capture at the end of the string a dot followed by one or more digits followed by a double quotation mark which is a group. In the substitution field, place %code% or %code% is the value of the group catch in the case double quotation.
= > ^ catch in the example:
%pre%I imagine it is captured to be replaced by something else.
In sublime: select exp.regulates and:
%pre%On-line command:
%pre%I have the following string:
2014-10-12 17:04:29.996
It is a format timestamp
and is wrong because after the time there is .996
. To catch this snippet I used regex
:
\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{2,3}
How can I remove only the ending considering that I have many occurrences?
To capture the microsecond you can use the following regex \.\d+(")$
it says to capture at the end of the string a dot followed by one or more digits followed by a double quotation mark which is a group. In the substitution field, place or
$1
is the value of the group catch in the case double quotation.
= > ^ catch in the example:
DT_HR_ALTERACAO="2015-02-05 10:55:01.324"
^^^^^
I imagine it is captured to be replaced by something else.
In sublime: select exp.regulates and:
find= (DT_HR_ALTERACAO="\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\.\d{2,3}
replace=
On-line command:
perl -i.bak -pe 's/...find anterior.../$1/g' ex.xml
Using sed looks like this:
sed -r 's/\.[0-9]{3}"$//' nome-arquivo >> novo-arquivo
Adapted from @rray
response