Description of problem:
If you have string "ABC DEF GHI" and want to remove the first word, you will use
Ctrl+F, Search for "^[^ ]+", empty Replace with string, and in More Options
check Regular expressions.
The result of "Replace All" is " DEF GHI", with space at the beginning of the
If you would like to remove the first word _and_ the leading space, you'll use
regular expression "^[^ ]+ " -- note that here we've appended a space character
to the regular expression. However, the result of such search / replace is
"GHI". So appending a space to a regular expression somehow changed the meaning
of that "^[^ ] +" that preceded it.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Create new text document.
2. Write string "ABC DEF GHI".
3. Try to remove the first word including the space after it (ABC ) with regular
expression "^[^ ]+ ".
"ABC DEF " gets removed.
Only "ABC " should have got removed.
The problem happens both in the writter and in calc.
It seems that after the first replace the remaining string then matches the
pattern, and the replace all is getting re-run after the first replace where it
now matches the pattern again and so the second replace takes place.
i.e. for replace all, instead of
echo ABCZDEFZGHI | sed -r -e 's/^[^Z]+Z//'
echo ABCZDEFZGHI | sed -r -e 's/^[^Z]+Z//' | sed -r -e 's/^[^Z]+Z//'
Here's a more concise example, i.e. search string of
and no replace string to remove the first 3 characters, with the above example
it keeps removing a block of 3 characters until only 2 are left with "replace all"
Moving upstream, affects us all: i.e.