[OS X TeX] regular expression matching in TeXShop

Alan Munn amunn at msu.edu
Thu Dec 21 14:34:31 EST 2006

I was thinking about a simple solution to Alain's problem of
inserting a new column into a tabular by using a regex replace, but I
seem to have (re-)encountered a problem:  the beginning of line match
character doesn't seem to work as expected.

Suppose I have the following table:

\begin{tabular}{lllllllll}
A & B & C & D & E & F & G & H & I & J\\
A & B & C & D & E & F & G & H & I & J\\
A & B & C & D & E & F & G & H & I & J\\
A & B & C & D & E & F & G & H & I & J\\
A & B & C & D & E & F & G & H & I & J\\
A & B & C & D & E & F & G & H & I & J\\
A & B & C & D & E & F & G & H & I & J\\
\end{tabular}

So the regular expression

^(([^\&]*\&){1,3})

Should match the first 3 columns of the table (assuming I position
the cursor before the first character of the first row.)

This would allow an easy way to insert a column after e.g. the third
row, by making the replace field "\1  & "

But for some reason, the expression doesn't seem to pay attention to
the beginning of the line, so if you search at the beginning of the
first line of the table, and it correctly selects the first three
columns, but when you click 'Next' you get the next three columns
rather than the first three of the rest of the line.

Why is this?  Simple expressions like ^foo do seem to match at the
beginning of the line.  Is this my error, or a bug?

I've noticed this before, and just given up trying to match line
beginnings, although it's a very useful thing to be able to do.

Alan

--
Alan Munn                                                   amunn at msu.edu
Department of Linguistics                                   amunn at acm.org
and Germanic, Slavic, Asian and African Languages   Fax.  +1-517-432-2736
Michigan State University, East Lansing MI 48824    Tel.  +1-517-355-7491

------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/