i'm having problems trying replace text before word using c# want delete text found before specific word. tried didn't work
string filecomplete = file.readalltext(path.getfullpath(ofd.filename)); string nonimportant = ".*?(?=word)"; string file = system.text.regularexpressions.regex.replace(filecomplete, nonimportant, string.empty); what want keep text after word , delete before.
thanks,
following option uses matchevaluator syntax of regex.replace. note need put word in place , capture comes after in capture group via ().
string nonimportant = ".*?(word.*)"; string st = "aslkfdalksdwordewot"; string file = regex.replace(st, nonimportant, (match m) => string.format("{0}",m.groups[1]));
Comments
Post a Comment