in reply to substituting constants within regex?

Nobody's mentioned that '^M' isn't the way you express a newline. It looks like you're trying to remove all those ^Ms you see in your files. Those are not really "caret character" plus "letter m character" (which is what you describe), but a special character called a carriage return that just appear that way in editors.

People who see this problem are likely using some form of Unix. You likely have a program called dos2unix on your system. Use that on your files.

Barring that, here's a perl one-liner from the Unix prompt that will do the same thing.

% perl -pi~ -e 's/\r//' *.txt

If you really need to do this in your own code, the bit between the single quotes is useful to you.

Update: From above replies, it looks like you do know the difference between '^M' and '\r', but I hope the information is still useful for yourself or others.

--
[ e d @ h a l l e y . c c ]