The other answers almost got it right. The find expression is correct:
\b(c[a-z]*)\b
I've used *
in place of +
in order to match c
as a single word, and I've added a trailing \b
to make the word limits more clear, but the original form is OK.
The replacement string should be:
$1 text
This does accord with Jim K's documentation link, but it is rather confusing in this area.
Specifically, \1
can be used in the search expression, to repeat a string matched earlier in the expression, but $1
must be used in the replacement string. The use in the search string means that (a.b).*\1
will match a
and b
with a character between, followed by a
and b
with the same character between. This is not the same as a.b.*a.b
, where the intervening characters may be different. The example in the documentation link is correct, but does nothing to explain where it will be useful.
As a final note, my version 5.1.4.2 of LibreOffice Writer refuses to make substitutions when the search string starts with \b
, although it finds all the instances correctly; a trailing \b
works as expected. This is a bug - OpenOffice 4.1.3 works correctly. The work-round is to use ([^a-z]\bc[a-z]*)\b
as the search string with the same replacement string: this works in all cases except when the first word of the document begins with c
.