Ad
Algorithms
Logic
Code
Diff
  • import re
    def get_nth_words(string, n):
        if n < 1: 
            return ""
        else:
            return re.compile(r"\w+").findall(string)[n-1:n]
    • import re
    • def get_nth_words(string, n):
    • if n < 1:
    • return ""
    • else:
    • return ' '.join(string.split()[n-1::n])
    • return re.compile(r"\w+").findall(string)[n-1:n]
Strings
Data Types
Code
Diff
  • function lastChar(string) {
      return string.split('').pop();
    }
    • const lastChar=s=>[...s].pop()
    • function lastChar(string) {
    • return string.split('').pop();
    • }