I am trying to manipulate text output from a web scrape I have done. I want a regex function that ONLY for strings that include the notation "-" to remove words from after this in each string.
The function '\s*(.*)(?=-)'
works, but removes all text from strings that don't have this notation.
How can I write a function that only affects strings with the "-" notation?
To give context, I am mining real estate agency information, and some entries (not all ) include the specific branch which is delineated using a "-"
However, for the country wide statistical analysis, I don't want the names of the specific branches as this makes it more difficult to format the data effectively.
Attached is a screenshot detailing what the input/desired output should be. enter image description here