using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(""(?:\\.|[^""\\])*""|'(?:\\.|[^'\\])*'|(?:[^/\n""']|/[^/*\n""'])+|\n)|(/\* (?:[^*]|\*[^/])*\*/)|(?://(.*)$)$";
string substitution = @"\1";
string input = @"//Bienvenue sur ma carte!
//Par Samuel ""Déjeuner d'aujourd'hui"" Lapointe
MAP {
CONFIG: 'ON_MISSING_DATA' 'IGNORE'
##CONFIG: ""MS_ERRORFILE"" ""../debugFile.log""
CONFIG: 'PROJ_LIB' '../'
FONTSET: '../fonts.lst'
IMAGETYPE: png
MAXSIZE: 4000
SIZE: 800 800
UNITS: meters
EXTENT: -20405648.939901 -17712669.979681 20314497.045109 19408951.476421
IMAGECOLOR: '#C6E2F2'
SHAPEPATH: '../pdata/natural_earth/'
WEB {
METADATA {{
""ows_enable_request"" ""*""
""wms_srs"" ""EPSG:900913 EPSG:4326 EPSG:3857""
""labelcache_map_edge_buffer"" ""10""
""wms_title"" ""grid""
""wms_onlineresource"" ""http://mapserver.com:8081/cgi-bin/mapserv?map=/opt/scribeui/workspaces/blabla.map"" //Un lien!
}}
IMAGEPATH: '/tmp/ms_tmp/'
IMAGEURL: '/ms_tmp/'
}
DEBUG: 5
PROJECTION {{
""init=epsg:900913""
}}
INCLUDE: '../symbols.map'
}//C'est la fin!
";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx