java - Text Mining sql schema files -
i have collection of big sql files. files want keep "create table" , "alter table add constraint foreign key" statements. there toll can use mine 2 regular expressions? know use grep don't have linux
you can build small java program obtain such sentences. e.g.:
string input = new string(files.readallbytes(paths.get("file.sql")), "utf-8"); string regex = "(?i)((create table|alter table add constraint foreign key)[^;]+;)" .replace(" ", "\\s+"); pattern pattern = pattern.compile(regex); matcher matcher = pattern.matcher(input); while (matcher.find()) { system.out.println(matcher.group()); }
Comments
Post a Comment