View Single Post
 
Old 06-30-2014, 12:39 PM
Robert2 Robert2 is offline Windows 8 Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 175
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

This is because the repetition counters @ and {1,} behave differently. @ performs “lazy matching” and is happy with one instance of the preceding character or character set. {1,} performs “greedy matching” and gobbles up as many instances of the preceding character or character set as it can.

Let’s take “Daryl Paer 2013” as an example.

([!0-9^13]@)( )

catches “Daryl ” first, then goes on to catch “Paer ” (and goes on until it finds the final 4 digits and paragraph end mark).

On the other hand,

([!0-9^13]{1,})

catches “Daryl Paer ” directly. This is why “([!0-9^13]{1,})( )(<[0-9]{4})^13” does not work. There is no need to search for the space character preceding the 4 digits. It has already been found by ([!0-9^13]{1,}).

Now

([!0-9^13]{1,})( )(<[0-9]{4})^13

would work if you removed the space character from the search pattern:

([!0-9^13]{1,})(<[0-9]{4})^13

With such a search string, the Replace pattern itself needs to insert the space character after the 4 digits:

\2^32\1^p

Note that you could also use the following pattern:

Find:

([!0-9^13]@)(<[0-9]{4})^13

Replace:

\2^32\1^p

By the way, ^32 is the code for a space character.

HTH.
Reply With Quote