Examine line at '.'.
Determine if index is in a URL or not.
Replace occurrences of pat with withpat.
Search for the next occurence of the character at '.'. If character is a (){}[]<>, search for matching bracket. If '.' is on #if, #elif, or #else search for next #elif, #else or #endif. If '.' is on #endif, search backwards for corresponding #if.