Dear textmate experts,
I have a text file with lines like this:
dog={brown, bark}, cat={white, purr}, mouse={gray, beep},
I would like to end up with this:
dog={brown, bark}, cat={{white, purr}}, mouse={gray, beep},
Replacing "cat={" by "cat={{" is trivial, but how can I replace the closing brace "}" by "}}" for that lines? I tried to work with regular expressions and ^.*cat={.*$ matches the lines starting with "cat={", but I couldn't manage to tell textmate's "Find" to basically add something to a line. I also seems to me that although the "Find"-box in textmate's "Find" can deal with regular expressions, the "Replace"-box ignores regular expressions.
I know textmates "Edit Each Line in Selection", but I can't select all lines starting with "cat={" by hand, there are simply too many in my file.
Cheers,
Marius
I have a text file with lines like this:
dog={brown, bark}, cat={white, purr}, mouse={gray, beep},
I would like to end up with this:
dog={brown, bark}, cat={{white, purr}}, mouse={gray, beep},
Try
Find: ^(.*cat={)(.*)(},\s*)$
Replace: $1{$2}$3
See more about regular expression replace in TextMate here: http://manual.macromates.com/en/regular_expressions#replacement_string_synta...
/Björn
What if you first GREP for the lines with "cat=" and then pipe that to SED to replace the '{' and '}'
---- Brian H binarynomad@gmail.com http://www.binarynomad.com
On Apr 6, 2011, at 6:26 AM, Marius Hofert wrote:
Dear textmate experts,
I have a text file with lines like this:
dog={brown, bark}, cat={white, purr}, mouse={gray, beep},
I would like to end up with this:
dog={brown, bark}, cat={{white, purr}}, mouse={gray, beep},
Replacing "cat={" by "cat={{" is trivial, but how can I replace the closing brace "}" by "}}" for that lines? I tried to work with regular expressions and ^.*cat={.*$ matches the lines starting with "cat={", but I couldn't manage to tell textmate's "Find" to basically add something to a line. I also seems to me that although the "Find"-box in textmate's "Find" can deal with regular expressions, the "Replace"-box ignores regular expressions.
I know textmates "Edit Each Line in Selection", but I can't select all lines starting with "cat={" by hand, there are simply too many in my file.
Cheers,
Marius
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate