It’s hard for me to find a regular expression. I have suggestions: "1A11 - Car engine control unit (VECU) (behind the plate)" "1A1K5 - rear view of the car (front view)" I want to trim my sentence from (----), I have this regular expression to do this "@" \ s * ([^)] *), but the problem with this is that, as in my first sentence, (VECU) is an abbreviation, so I need to keep it, but it is regular expression doesn't work if i have 2 () (). How can I change my regex 2 to trim only the last () of a sentence?
if (!reportMode)
{
stream = GetStream(files);
List<String> fileContent = new List<String>();
using (StreamReader sr = new StreamReader(stream))
{
String line = "";
Boolean isInThere = false;
while (!sr.EndOfStream)
{
line = sr.ReadLine();
if (line.Contains(title))
{
Int32 index = line.IndexOf(" - ");
String revisedLine = line.Substring(index + 3).Trim();
String str = Regex.Replace(revisedLine, @"\s*\([^\)]*\)", "").Trim();
if (Regex.IsMatch(str, String.Format("^{0}$", title)))
isInThere = true;
}
fileContent.Add(line);
}
source
share