Skip to content

Instantly share code, notes, and snippets.

@namjae
Created May 30, 2016 01:13
Show Gist options
  • Select an option

  • Save namjae/c2df1b7d7e412dcbaaf64cb050c52965 to your computer and use it in GitHub Desktop.

Select an option

Save namjae/c2df1b7d7e412dcbaaf64cb050c52965 to your computer and use it in GitHub Desktop.
regex (SQL 주석 제거)
import java.io.BufferedReader;
import java.io.FileReader;
public class Test {
public static void main(String[] args) {
String PATTERN_COMMENT = "/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/";
try {
String testSQL = readText("test1.sql");
System.out.println("===[origal text][start]================================================================");
System.out.println("\t" + testSQL);
System.out.println("===[origal text][end]================================================================");
String result = testSQL.replaceAll(PATTERN_COMMENT, "");
System.out.println("===[result text][start]================================================================");
System.out.println(result);
System.out.println("===[result text][start]================================================================");
} catch(Exception e) {
e.printStackTrace();
}
}
private static String readText(String fileName) throws Exception {
BufferedReader br = new BufferedReader(new FileReader(fileName));
StringBuffer fullText = new StringBuffer();
String readLine = "";
while((readLine = br.readLine()) != null) {
fullText.append(readLine).append("\n");
}
return fullText.toString();
}
}
/*========================================================================
5179=PROJCS["Korea 2000 / Unified CS", GEOGCS["Korea 2000", DATUM["Geocentric datum of Korea", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6737"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4737"]], PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], PARAMETER["central_meridian", 127.5], PARAMETER["latitude_of_origin", 38.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 1000000.0], PARAMETER["false_northing", 2000000.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","5179"]]
5179=PROJCS["Korea 2000 / Unified CS", GEOGCS["Korea 2000", DATUM["Geocentric datum of Korea", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6737"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4737"]], PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], PARAMETER["central_meridian", 127.5], PARAMETER["latitude_of_origin", 38.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 1000000.0], PARAMETER["false_northing", 2000000.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","5179"]]
5181=PROJCS["Korea 2000 / Central Belt", GEOGCS["Korea 2000", DATUM["Geocentric datum of Korea", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6737"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4737"]], PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], PARAMETER["central_meridian", 127.0], PARAMETER["latitude_of_origin", 38.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 200000.0], PARAMETER["false_northing", 500000.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","5181"]]
5182=PROJCS["Korea 2000 / Central Belt Jeju", GEOGCS["Korea 2000", DATUM["Geocentric datum of Korea", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6737"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4737"]], PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], PARAMETER["central_meridian", 127.0], PARAMETER["latitude_of_origin", 38.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 200000.0], PARAMETER["false_northing", 550000.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","5182"]]
======================================================================== */
DELETE FROM spatial_ref_sys
WHERE srid IN (4927, 2096, 2097, 2098, 5167, 5168, 5173, 5174, 5175, 5176, 5177, 5178, 5179, 5180, 5181, 5182, 5183, 5184, 5185, 5186, 5187, 5188);
/*========================================================================
주석 테스트 입니다.
======================================================================== */
DELETE FROM spatial_ref_sys
WHERE srid IN (4927, 2096, 2097, 2098, 5167, 5168, 5173, 5174, 5175, 5176, 5177, 5178, 5179, 5180, 5181, 5182, 5183, 5184, 5185, 5186, 5187, 5188);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment