View Single Post
Old 10-14-2011, 09:21 PM   #8
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
Posts: 13,357
Karma: 78877538
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
Quote:
Originally Posted by theducks View Post
I think that should be (a back reference for each match)
\1\2

Since the spac between other match elements is not in side a reference (), it will be lost when replacing only the 2 back references.
Actually, I think the way it works is that the entire regex ONLY matches the first occurence of a single word character followed by a period and space.

Since the (?=\w\.) is as chaley says "(?= is a positive lookahead assertion. It lets the preceding match only when the following matches, but the lookahead part doesn't "eat up" any of the string." this means the only characters "consumed" by the reg ex. are the initial sequence "(\w\.) " and that is replaced by the (1) which is that initial \w\. sequence.
PeterT is offline   Reply With Quote