Skip to content

Instantly share code, notes, and snippets.

View ahmadelmorshedy's full-sized avatar

Ahmad el-Morshedy ahmadelmorshedy

View GitHub Profile
PLEASE DO IT CAREFULLY, SPECIAL CASES MAY OCCUR, SO BULK REPLACE IS NOT RECOMMENDED
find: (:)(((?!:).)*?)(\s*=>)
replace: ${2}:
explanation:
i. the brackets are used to create capture/matches groups, so that you can ommit the : (group 1) and the => (group 3)
and use only the key (group 2)
ii. ((?!:).)*? finds KEY text, it searches any text, expect it should not have : included, that's the role of (?!:) part,
the ? is used to mark a non-greedy search, if not marked, some text like :KEY1 => VAL1, :KEY2 => VAL2 will end up