in reply to Re^3: Writing to file...
in thread Writing to file...

The ^ character has meaning within a regex (anchor the following stuff at the beginning of line). If you want this ^ character be interpreted without the contextual meaning, ie literally, you need to "escape it" with a "\".

I'm not really sure what you are trying to do here. A simple example with a)I have this "X" and b)I what that "Y" would be helpful. BTW:

[a]|[c]|[t]|[g]{6} #looks like a char set [actg]{6}