C# Regex not returning -
i'm working on practice problem gives me longer set of strings. need pull strings out of quotation marks (wh
// names string[] composed of names these: "bob", "joe", "frank", etc... // (the ""s part of string, not string designations). suppose makes them "\"bob\"", etc... foreach(string name in names) { regex regex = new regex("/\"(.+)\"/"); match match = regex.match(name); console.writeline (match.value); if (match.success) { console.writeline("string: {0} , match value: {1}", name, match.groups[1].value); } } i'm not logging out anything. i've tried referencing .value several ways, can't log normal strings either i'm not getting matches off of regex. i've followed couple of examples too.
regex101 tells me should matching fine, i've got have error in c# implementation. can't figure out. need set me straight. thanks!
remove forward slashes in regex. used indicate start , end of regular expression in languages or formats, not needed when creating 1 through regex class.
regex regex = new regex("\"(.+)\""); result:
"bob"
string: "bob" , match value: bob
Comments
Post a Comment