Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I imported a text and seperated al words by using StringCases. After this I would like to manipulate the text, for example to replace all singular verbs to plural. When I use StringReplace, then Mathematica search for a part of the string and replaced it.

For example

texttest = "walking walk routes walks"
texttest1 = StringCases[texttest, RegularExpression["\\w(?<!\\d)[\\w'-]*"]];
newwords= {"walk" -> "walking", "walks" -> "walking"};
texttest2 = StringReplace[texttest1, newwords];

The result is:

{"walkinging", "walking", "routes", "walkings"}

I would like to get: {"walking", "walking", "routes", "walking"}.

share|improve this question

1 Answer 1

up vote 2 down vote accepted
texttest = "walking walk routes walks"
StringSplit[texttest, " "] /. {"walk" -> "walking", "walks" -> "walking"}

{"walking", "walking", "routes", "walking"}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.