I have a string like
Pakistan, officially the <a href="Page.aspx?Link=Islamic Republic of Pakistan">Islamic Republic of Pakistan</a>
Now I am using
System.Text.RegularExpressions.Regex.Replace(inputText, "(\\bPakistan\\b)", "something");
to replace Pakistan outside the tags. But I don't want to replace Pakistan occurring within the <a></a>
tags.
Edit: an actual string
Pakistan (Urdu: پاکِستان), officially the Islamic Republic of Pakistan, is a country in South Asia. It has a 1,046-kilometre (650 mi) coastline along the Arabian Sea and Gulf of Oman in the south and is bordered by Afghanistan and Iran in the west, India in the east and China in the far northeast.[6] Tajikistan also lies very close to Pakistan but is separated by the narrow Wakhan Corridor.
And An array of strings
string[] links={"Pakistan","Islamic Republic","Republic of Pakistan","South Asia","Arabian Sea","Gulf","Oman","Gulf of Oman","the south","in the south","Afghanistan","Iran","the west","in the west","west India","the east","China","Tajikistan","the narrow","Wakhan Corridor","Central Asia","the Middle","Middle East","the Middle East"}
I want to replace every occurrence of every string in this array with <a href="page.aspx?link=thisString">thisString</a>
. and I could not correctly add links to strings like "Republic of Pakistan" where Pakistan is also another string in this array.