On Sat, Aug 05, 2006 at 03:37:29PM +0100, Ben Dougall wrote: > > On Saturday, August 5, 2006, at 03:27 pm, David Livesay wrote: > > >On Aug 5, 2006, at 10:19 AM, David Livesay wrote: > > > >>I would never ask anyone to write Perl. You can do this with > >>Find/Replace using regular expressions, which are bad enough. ;-) > >> > >>Search for: (\d+)(\t)(.+\r)(\t)(.+\r)(\t)(.+\r) > >>Replace with: \1\2\3\1\4\5\1\6\7 > >> > >>Make sure "Use Grep" is checked. > >> > >>If it doesn't work I may need to see part of the actual file. This > >>worked on your example. > > > >Actually, this can be simplified a little: > > > >Search for: (\d+)(\t.+\r)(\t.+\r)(\t.+\r) > >Replace with: \1\2\1\3\1\4 > > a reoccurring problem i find with regex is a seeming > deficiency/inability to deal with varying number of things. what > happens if the requirement given was: > [snip] > is that doable with regex? that sort of thing often stumps me.
No, you cannot solve that problem with a single Find/Replace. You can match the lines all at once, but you can't get back all the chunks you want to keep. The best you could do is create a regex that fixes just the first line in each group, then apply it over and over until all the lines have been updated. This is why it's beneficial to be able to use a programming language such as Perl. Ronald -- ------------------------------------------------------------------ Have a feature request? Not sure the software's working correctly? If so, please send mail to <[EMAIL PROTECTED]>, not to the list. List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml> List archives: <http://www.listsearch.com/BBEditTalk.lasso> To unsubscribe, send mail to: <[EMAIL PROTECTED]>
