On Feb 5, 7:11 am, zavi...@gmail.com (zavierz) wrote: > Hi, I am trying to modify a LaTex file which is plain text. > The file contains lines similar to the following, but each line is > followed by text, so that: > > Article 1 Cats > Article 2 Dogs > Article 3 Fish > Article 4 Ferrets > > etc. > > I would like to modify the file so that each referenced line is > changed as follows: > > \subsection*{Article 1 Cats} > \subsection*{Article 2 Dogs} > \subsection*{Article 3 Fish} > \subsection*{Article 4 Ferrets} > > Here's code which was suggested to me, but when I execute it I'm > returned to the command line and nothing happens: > > #!/usr/bin/perl > s/^(Article\s+[0-9]+\s+\N*\S)/\\subsection*{$1}/gm ^^^ s/^(Article\s+[0-9]+\s+\N*)/\\subsection*{$1}/gm"
I believe the problem is the extraneous \S. The regex should be: either: ^(Article\s+[0-9]+\s+\N*) or: ^(Article\s+[0-9]+\s+\S*) BTW, \N is a newer regex experimental escape. >From perldoc perlre: \N Any character but \n (experimental) > ... -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/