# Tahir Hassan's Blog

My Technical Notes

## Monday, 20 June 2016

### Emacs Regex Perculiarities

Given the input:


DefaultFolder
DescriptionFormat


To turn them into properties such as:


public string <propname> { get; set; }


We use query-replace-regexp, which accepts a search expression and then a replacement string. $$.*$$ is our search expression. Emacs expects that we escape the bracket characters, even though they are a part of the regex,


public string \1 { get; set; }


is our replacement term. Notice the use of \1 which is our input. This results in (notice the title-casing):


Public String DefaultFolder { Get; Set; }
Public String DescriptionFormat { Get; Set; }
Public String Username { Get; Set; }
Public String Password { Get; Set; }


The title casing is the result of "case conversion", which can be turned off by using (stick in init?):


(setq case-fold-search nil)