What are the uses of split(), sub() and subn() methods?

Discussion RoomCategory: Interview QuestionWhat are the uses of split(), sub() and subn() methods?
Ashly asked 5 years ago
  • Split():Its uses a regex pattern to split any given string into a created list.
  • Sub() :It will find all the substring where this regex pattern will match and then replace the string.
  • Subn() :It is similar to a sub(), it will return the new string along with the other no. of replacements.
Scroll to Top