To be in the world but not of it” is a familiar characterization of the challenge of the Christian life. Though not exactly scriptural, the formula captures something of the spirit of John 17:15-18:
I pray not that thou shouldest take them out of the world, but that thou shouldest keep them from evil. They are not of the world, even as I am not of the world. Sanctify them through thy truth: thy word is truth. As thou hast sent me into the world, even so have I also sent them into the world.
John teaches that we are sent into the world, just as Christ was sent. But we are not of the world.