Go to wal mart or a drug store get no bite nail stuff in the nail isle, apply 4 - 5 times a day and use until it stops, also works for thumb sucking.
None chemical way, HOT HOT hot sauce on their fingers at night after bath, and re apply a few times a day.
If neither work try and ask the child why they do this, and explain it is not good for them to do this, and they will hurt them selfs and that they should stop. I did that with my 2 yr old and guess what now the only thumb sucking is at night and rare or when its almost bed time, and nail bitting has stopped.
I did both, at young ages, and stooped when my dad got the nail stuff. My child we had to stop doing this because she picks her skin, bites her nails & cuticle tell it was raw. She would suck her thumb until skin was coming off.
Yes anxiety can cause this but our pediatrician who is a specialist because we have a special needs child, said that we should get her to stop doing it and try and get her focused on something else we do books & color with crayons a lot. And that helps.
Good luck.