An actor who appeared in "The 40-Year-Old Virgin" was charged with attempted murder Tuesday after police said he stabbed his former girlfriend more than 20 times.

Shelley Malil, 43, remained in custody on $2 million bail. He was arrested late Monday as he left a train in Oceanside, Calif., the San Diego County Sheriff's Department said.

Malil was charged late Monday with attempted murder and was scheduled to be arraigned today in Vista, north of San Diego, said Paul Levikow, a spokesman for the San Diego County District Attorney's Office.