c# - Regex to match a substring within 2 brackets, e.g. [i want this text] BUT leave out the brackets? -
I have almost managed to find Regex, which means I want here
< Pre> reggaex r1 = new regenges (@ "\ [(* * * * *] \]"); String line = HEADERNAMES [COL1, COL2, COL3, COL4]; Match match = R1 Match (line); String result = match. Toasting ();
Output: "[COL1, COL2, COL3, COL4]";
I know I can use it:
Results. ("[", ""); result. Change ("]", "");
What I really want, but I was wondering if there was a way of leaving the demeter [and] with remix results without string methods.
I would have thought that using Reggae is a more elegant solution ??
Thanks in advance.
reggaex r1 = new reggae (@ "\ [(. +) \]" ); String line = "HEADERNAMES [COL1, COL2, COL3, COL4]"; // Regx group is called Capture Group (i.e. the group archive string match = r1.Match (/) in the things captured between / (/) .group [1]. Value; // match = "COL1, COL2, COL3, COL4 "
Comments
Post a Comment