openoffice writer - What is a regex to replace "### " with "###. " -
where ### 3 or 4 digit number followed space , want replace same number followed space , period.
i using regex search & replace in open office , tried
"[0-9][0-9][0-9] "
which found numbers looking for
replace with
$&
or
"[0-9][0-9][0-9]. "
neither worked
in regex implementations, "(\d\d{3,4}) " selects 3 or 4 digit number nondigit prefix (otherwise find 2345 in 12345). way in ">1234 <" find ">1234 ", , put in $1 or \1. so:
s/(\d\d{3,4}) /\1. /g
otherwise instead of \d can use word boundary, \< or \b or < depending on dialect.
edit: if \d not supported, in (apparently) command line sed, if have sworn contrary, use [0-9] replace \d:
sed -e 's/\([^0-9][0-9]\{3,4\}\) /\1. /g'
test:
$ echo "this 12345 , 1234 , 123 , 12 , 1. 123. 1234." \ | sed -e 's/\([^0-9][0-9]\{3,4\}\) /\1. /g'
result:
12345 , 1234. , 123. , 12 , 1. 123. 1234.
Comments
Post a Comment