Check if before the last / there are an n

  1. Reverse the string
  2. find first /
  3. check if next char is n

Alternatively iterate from the back rather than from front.