vb.net - Replace "," to the word "and" but avoid replace "and" inside the parenthesis -
this question exact duplicate of:
sample:
my string = englishgrammar(verb,noun , adjectives),math(algebra,trigometric , geometric), science(physics,chemistry , ecology)
i want output this: englishgrammar(verb,noun , adjectives),math(algebra,trigometric , geometric) , science(physics,chemistry , ecology)
i have no idea how can fix this? using vb.net
so want replace last occurrence of string new string ..
private function replacelastoccurenceof(s string, texttoreplace string, newtext string) string dim lastcommaindex integer = s.lastindexof(texttoreplace) return s.remove(lastcommaindex, 2).insert(lastcommaindex, newtext) end function
and use it
strtest = replacelastoccurenceof(strtest, "),", ") and")
Comments
Post a Comment