For example, how can I strip away the names of the states in this string and only keep he two character abbreviations?
(In my file the state names and abbreviations are separated by a tab.)
Alabama AL Alaska AK Arizona AZ Arkansas AR California CA
Also...how could I turn this string:
AL AK AZ AR CA
into: AL¶AK¶AZ¶AR¶CA
Hi, regular expressions will be your friend:
For example, how can I strip away the names of the states in this string and only keep he two character abbreviations?
(In my file the state names and abbreviations are separated by a tab.)
Alabama AL Alaska AK Arizona AZ Arkansas AR California CA
search for: ^[^\t]*?\t
and replace by ""
and press "Replace All"
Also...how could I turn this string:
AL AK AZ AR CA
into: AL¶AK¶AZ¶AR¶CA
search for: \n
and replace by: ¶
and press "Replace All"
Best, Hans
On 2015-07-15 08:32, Hans-Jörg Bibiko wrote:
Hi, regular expressions will be your friend: search for: ^[^\t]*?\t
and replace by ""
and press "Replace All"
I don't see how that regular expression will work. Try this:
^\w+\s+
Also, don't forget to check the "Regular Expression" option.
Alternatively, if you have a short list, like the one in the original example, you can hold done the Alt key and select only the text with the states. Delete the text and then just search and replace space with nothing to remove the spaces.
Thank you for your replies.
Where in the documentation can I see these type of things...that tab = \t
On 7/15/15, 1:32 AM, "Hans-Jörg Bibiko" bibiko@eva.mpg.de wrote:
search for: ^[^\t]*?\t
On 2015-07-16 05:50, jgalt wrote:
Thank you for your replies.
Where in the documentation can I see these type of things...that tab = \t
Here is the TextMate documetnatino for regular expressions [1]. Here is some general documentation about regular expressions [2].
[1] https://manual.macromates.com/en/regular_expressions [2] http://www.regular-expressions.info
Hi,
you can also do the whole thing without regex if you like:
1. Move the caret to the position right before the word California 2. Select the whole thing by pressing ⌘⇧↑ 3. Hit ⌥ to get multiple carets 4. Move to the end of the line by pressing ⌘→ 5. Select the current words — the abbreviations — by pressing ^W 6. Hit ← to move the caret before the abbreviations 7. Select the text until the beginning of the line: ⇧⌘← 8. Hit ⌫ to remove the selected text
After that you get
AL AK AZ AR CA
To move the words into a single line press ^Q. Then your text looks something like this:
AL AK AZ AR CA
If you want to get rid of the spaces:
1. Select one space character and move it into the find clipboard by pressing ⌘E 2. Select the whole line: ⇧⌘L 3. Use “Find All” to get all occurrences of the space character: ⌘F 4. Delete the spaces by hitting ⌫
Kind regards, René
On 15 Jul 2015, at 8:21 , jgalt jgaltusa@gmail.com wrote:
For example, how can I strip away the names of the states in this string and only keep he two character abbreviations?
(In my file the state names and abbreviations are separated by a tab.)
Alabama AL Alaska AK Arizona AZ Arkansas AR California CA
Also...how could I turn this string:
AL AK AZ AR CA
into: AL¶AK¶AZ¶AR¶CA
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 15.07.2015, at 08:21, jgalt jgaltusa@gmail.com wrote:
For example, how can I strip away the names of the states in this string and only keep he two character abbreviations?
(In my file the state names and abbreviations are separated by a tab.)
Alabama AL Alaska AK Arizona AZ Arkansas AR California CA
Also...how could I turn this string:
AL AK AZ AR CA
into: AL¶AK¶AZ¶AR¶CA
Here’s a small video that shows a simple workflow transforming the text with multiple cursors in one go:
https://www.dropbox.com/s/ns2hdpkivgkjert/TM2%20Multicursor%20workflow%20(1)...
Note that I simply paste “¶” at the end, if theres a dedicated key you can substitute with a key press...
Thanks everyone for the instructions and the video demo. It was very helpful.