English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing up some documentation, and I'm unsure which phrase to use:

Option X: Find all strings ending with foo.


Option X: Find all strings ending in foo.

Are both correct? (Google spits out both, strongly favoring with.) Which should I prefer?

share|improve this question
up vote 4 down vote accepted

"Ends in" is acceptable in the sense that words can end in a vowel; end in an "a"; etc. This is often shortened to:

"Word" ends in "d"

"Ends with" seems to fulfill the same use:

"Word" ends with "d"

But I typically think of "ends with" using larger things than letters:

"This phrase" ends with "phrase"

"This is a sentence" that ends with "sentence"

Really, though, both "in" and "with" are doable:

"Hungry" and "angry" both end in "gry."

"Hungry" and "angry" both end with "gry."

The only difference I can find is their usage outside of words:

Our journey ends in Texas.

Our journey ends with disaster.

To directly answer your question, both work just fine in the original context. Some people prefer one over the other; some workplaces will have a strict style guide dictating which should be used. At the end of the day, consistency is more important.

As for references, there isn't much to find other than looking at hits via Google. NGram searching for "ends in/with c" shows:

enter image description here

But that really doesn't mean much, given the propensity for quirks in searching algorithms. Just browsing pages found by Google is of virtually no help given how often people use both phrases.

share|improve this answer
What I great and insightful response. It is the best answer I got. I have asked several grammarians about this. Thank you very much. – Nikolai May 4 '11 at 22:36

Close call. I would say that "in" is asking for a very precise case, whereas "with" is for more general usage. For example:

Which words end in "ces"?


Which words end with a vowel

share|improve this answer

I would go with

Option X: Find all strings ending with foo.

It sounds more solid.

share|improve this answer
Thanks. Is "sounds more solid" the opposite of "sounds a bit shaky", or does it imply something else? :-) – Martin Jan 18 '11 at 9:33
It doesn't mean anything else, I just think that it's more convenient to use with. Personally, I've never seen ending in in technical documentations. That doesn't mean it's wrong, of course. It's up to you. ;) – Mehper C. Palavuzlar Jan 18 '11 at 9:50

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.