I receive definitions of words via json. Sometimes I receive stuff like this:
inclusa1.
(the number can also be 2, 3, and so on). How can I automatically detect (and remove) numeric characters that are appended to words?
Eg: This is acceptable:
people that live in 1 house.
Eg: This is not acceptable:
people1.
preg_replace('/(?<=[a-zA-Z])[0-9]/', '', $string);
This just removes any numeric characters preceded by an alpha.
Assuming a word is just made up of letters, this should work:
preg_replace('/([a-zA-Z])[0-9]+/', '$1', $string)
preg_replace('/(\b[A-Z]+)([0-9]+)/i', '$1', $string);