I want to replace hyphen character with space if it is NOT enclosed by digits on both sides.
string str = "Hefer 789-567 dfg-5mh";
str = Regex.Replace(str, @"[a-zA-Z]\-(\d+)", "$1");
Output
Hefer 789-567 df5mh
Desired output
Hefer 789-567 dfg 5mh
The problem you are describing in your title can be solved using this:
The problem you are describing in the body of your question can be solved using this:
Or without lookaround: