I am trying to parse the street name file for the project, and you need to remove the modifiers (Upper / Lower / Old / New / North / East / South / West ...) and the endings (street / road / path / lane ...), but I had no luck with regex.
The way it is configured at the moment is that the program will analyze the file one line (for example, the street) at a time and check it
I think the problem is to limit the words - I need, for example, the following transformations ...
Harrow Old Way → Harrow (that is, remove the "Old" prefix and "Path")
Chittock Mead → Chittock (Delete the final "Mid")
- But leave them alone, in a word:
Gold Lane → Gold (just remove the ending)
Eastley Avenue → Eastly (just remove the ending)
Upper West Avenue → West (remove the prefix and ending)
Obviously, things like South Street removed both. This is normal because I can discard an empty string.
Can someone give me an idea on how to do this? I read regular expressions and tried something for hours!