David Buddrige wrote: > Hi all, > > I have a group of C++ source files where I have the following text on > a single Lines: > > class MyReallyLongClassNameThatIsTooLongToFitInEightyCharacters : > public SomeClassTemplate<InstantiatedDataType> > > What I want to do is to split this line at the ":" so that everything > after the colon appears on the next line (indented 4 characters) like > so: > > class MyReallyLongClassNameThatIsTooLongToFitInEightyCharacters > : public SomeClassTemplate<InstantiatedDataType> > > > I have written the following code: > > while(<>) > { > $code_line = $_; > $length_of_codeline = length( $code_line ); > if ( $length_of_codeline > 80 ) > { > if ( $code_line =~ > m|class(\s)+([a-zA-z])+(\w)*(\s)+:(\s)+public(\s)+([a-zA-z])+(\w)*<[a-zA-Z]( \w)+>| > ) > { > # At this point, I know I've found the line, I need to > # split it somehow. > } > } > } > > This code identifies the line in question, but having done so, I am > not sure how to split it into two lines (at the colon). Can anyone > suggest how I'd do that? > > thanks heaps guys > > David Buddrige. 8-)
If the data is as stated, then this simplified regex should work for you as a starting place: if ( $code_line =~ m|(class[^:]+):\s+(public.+)|i ) { printf "%-s\n : %-s\n", $1, $2; Wags ;) ********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]