Alexander Grigoriev <alegrigor...@gmail.com> added the comment:
For example, sed: $ sed --version sed (GNU sed) 4.8 Copyright (C) 2020 Free Software Foundation, Inc. $ sed -e 's/-\?$/x/g' <<<'a-b-' a-bx Perl: $ perl --version This is perl 5, version 32, subversion 0 (v5.32.0) built for x86_64-msys-thread-multi Copyright 1987-2020, Larry Wall $ perl -e 'my $x="a-b-"; $x =~ s/-?$/x/g; print $x' a-bxx https://www.freeformatter.com/java-regex-tester.html Java Regular Expression : -?$ Entry to test against : a-b-c- String replacement result: a-b-cx During replacement or split, a match consumes the matched character. It's easy to forget that "end of line" should be considered a (pseudo)character and must also be consumed if it matched. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43714> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com