One of the 39 melochos that are forbidden on Shabbos is the melocha of borer, or separating. It is forbidden to separate the bad from the good. Under certain circumstances however separating may be permissible. Three qualifications must be met:
1. The good must be separated from the bad, instead of the bad from the good.
2. The separating must be done with your hand, not with a utensil.
3. The good that you are taking must be for immediate use, not to be put aside for later.
If all of these stipulations are met, then this is considered an act of regular eating rather than separating.
A practical application of permissible borer would be if one were to find an pit from a lemon in their salad. To remove the pit and throw it out would be forbidden. The salad must be eaten around the pit. Another option would be to move the salad to the other side of the plate away from the pit, or to another plate.
Ha’Rov Tzvi Erya Hyman/Meir Yeshiva Jerusalem