{"action":"created","issue":{"url":"https://api.github.com/repos/atom/atom/issues/10246","labels_url":"https://api.github.com/repos/atom/atom/issues/10246/labels{/name}","comments_url":"https://api.github.com/repos/atom/atom/issues/10246/comments","events_url":"https://api.github.com/repos/atom/atom/issues/10246/events","html_url":"https://github.com/atom/atom/issues/10246","id":124557339,"number":10246,"title":"Find and replace using tokens/patterns (without regex)","user":{"login":"nuno-agostinho","id":3199157,"avatar_url":"https://avatars.githubusercontent.com/u/3199157?v=3","gravatar_id":"","url":"https://api.github.com/users/nuno-agostinho","html_url":"https://github.com/nuno-agostinho","followers_url":"https://api.github.com/users/nuno-agostinho/followers","following_url":"https://api.github.com/users/nuno-agostinho/following{/other_user}","gists_url":"https://api.github.com/users/nuno-agostinho/gists{/gist_id}","starred_url":"https://api.github.com/users/nuno-agostinho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuno-agostinho/subscriptions","organizations_url":"https://api.github.com/users/nuno-agostinho/orgs","repos_url":"https://api.github.com/users/nuno-agostinho/repos","events_url":"https://api.github.com/users/nuno-agostinho/events{/privacy}","received_events_url":"https://api.github.com/users/nuno-agostinho/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-01T18:58:55Z","updated_at":"2016-01-01T19:47:12Z","closed_at":null,"body":"A token is simply a common pattern of what we'd like to search (for example, instead of using a regex pattern representing a word, a number, a tab, a break, etc. we could insert a token that represents the same thing).\r\n\r\nIn OS X's built in find/replace (available in TextEdit and Notes, for example), although it's not possible to use regex we can use the following tokens to represent commons patterns:\r\n![screen shot 2016-01-01 at 18 12 39](https://cloud.githubusercontent.com/assets/3199157/12071731/4a39ff04-b0b3-11e5-8a62-07659c21eae6.png)\r\n\r\nUsing tokens is easier than having to remember common used regex patterns for a simple find and replace. Also, a great common use case for this is to use the result of the pattern searched when replacing. For example, imagine you have a text like this:\r\n```\r\nyou thank\r\ndiem carpe\r\npython monty\r\n```\r\n\r\nAnd you'd like to find in the text WORD1 WORD2 and replace matches with WORD2 WORD1. The resulting text would be:\r\n```\r\nthank you\r\ncarpe diem\r\nmonty python\r\n```\r\n\r\nSimply inserting the same tokens in the Replace field would allow to find and replace WORD1 WORD2 with WORD2 WORD1. This is achievable in the aforementioned OS X's find/replace feature and is presented like this:\r\n![screen shot 2016-01-01 at 18 09 31](https://cloud.githubusercontent.com/assets/3199157/12071733/714be76a-b0b3-11e5-8578-20f6138088f4.png)"},"comment":{"url":"https://api.github.com/repos/atom/atom/issues/comments/168334187","html_url":"https://github.com/atom/atom/issues/10246#issuecomment-168334187","issue_url":"https://api.github.com/repos/atom/atom/issues/10246","id":168334187,"user":{"login":"YemSalat","id":2361381,"avatar_url":"https://avatars.githubusercontent.com/u/2361381?v=3","gravatar_id":"","url":"https://api.github.com/users/YemSalat","html_url":"https://github.com/YemSalat","followers_url":"https://api.github.com/users/YemSalat/followers","following_url":"https://api.github.com/users/YemSalat/following{/other_user}","gists_url":"https://api.github.com/users/YemSalat/gists{/gist_id}","starred_url":"https://api.github.com/users/YemSalat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YemSalat/subscriptions","organizations_url":"https://api.github.com/users/YemSalat/orgs","repos_url":"https://api.github.com/users/YemSalat/repos","events_url":"https://api.github.com/users/YemSalat/events{/privacy}","received_events_url":"https://api.github.com/users/YemSalat/received_events","type":"User","site_admin":false},"created_at":"2016-01-01T19:47:12Z","updated_at":"2016-01-01T19:47:12Z","body":"You have a bad example. There is already a regex pattern for 'Word', which is `\\w`\r\nSo you can do: `(\\w+) (\\w+) -> $2 $1` To get the same effect."}}