$ cat test.txt |perl -pe 's/(\w+)([A-Z])/\1\. \2/g'
made. Style
facilitated. One
Anti-magnetic. Quality
RE pedanticism: \1 et alia are only supposed to be used on the LHS of the
subst cmd. You'd want:
cat test.txt |perl -pe 's/(\w+)([A-Z])/\1\. \2/g'
or no need for cat (ye olde pipeline debate ;-):
perl -pe 's/(\w+)([A-Z])/$1. $2/g' test.txt
You're supposed to use the \1 format to match a current match, like a
duplicated word
$ echo "her here hear hear hop hip hip ho!" | perl -pe
's/(\w+)\s+\1\s+/double "${1}s" /g;'
her here double "hears" hop double "hips" ho!
Might you need to worry about 2 capital letters?
perl -pe 's/([a-z])([A-Z])/$1. $2/g' test.txt
Non-ascii text (ranges like 'a-z' are only true ranges in ascii)? Use
POSIX class shorthand names (if your Perl is new enough):
perl -pe 's/([[:lower:]])([[:upper:]])/$1. $2/g' test.txt
a
a
----------------------
Andy Bach
Systems Mangler
Internet: [email protected]
Voice: (608) 261-5738;
Cell: (608) 658-1890
Civilization advances by the number of important operations
which we can perform without thinking about them.
--Alfred North Whitehead_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs