re = /interface (\w+)(\s+){([?\w\s\d:;()\[\]=>\.]*)};/m
str = '/**
* Analytic instance returned from initialization
* @property identify - Identify a user
* @property track - Track an analytics event
* @property page - Trigger page view
* @property user - Get user data
* @property reset - Clear information about user & reset analytics
* @property ready - Fire callback on analytics ready event
* @property on - Fire callback on analytics lifecycle events.
* @property once - Fire callback on analytics lifecycle events once.
* @property getState - Get data about user, activity, or context.
* @property storage - storage methods
* @property plugins - plugin methods
*/
export interface AnalyticsInstance {
identify: Identify;
track: Track;
page: Page;
user: User;
reset: Reset;
ready: Ready;
on: On;
once: Once;
getState: GetState;
storage: Storage;
plugins: Plugins;
};
interface AnalyticsPluginBase {
name: string;
EVENTS?: any;
config?: any;
initialize?: (...params: any[]) => any;
page?: (...params: any[]) => any;
track?: (...params: any[]) => any;
identify?: (...params: any[]) => any;
loaded?: (...params: any[]) => any;
ready?: (...params: any[]) => any;
};'
subst = 'interface $1$2{$3}'
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html