5 kyu

String incrementer

22,671 of 52,254parceval

Description:

Your job is to write a function which increments a string, to create a new string.

  • If the string already ends with a number, the number should be incremented by 1.
  • If the string does not end with a number. the number 1 should be appended to the new string.

Examples:

foo -> foo1

foobar23 -> foobar24

foo0042 -> foo0043

foo9 -> foo10

foo099 -> foo100

Attention: If the number has leading zeros the amount of digits should be considered.

Regular Expressions
Strings

Stats:

CreatedJan 4, 2015
PublishedJan 4, 2015
Warriors Trained132783
Total Skips23715
Total Code Submissions450046
Total Times Completed52254
JavaScript Completions22671
Python Completions22686
Ruby Completions1787
Kotlin Completions883
COBOL Completions8
Factor Completions11
Rust Completions407
C Completions464
Java Completions1961
C++ Completions1731
Scala Completions103
Total Stars3122
% of votes with a positive feedback rating90% of 4764
Total "Very Satisfied" Votes3931
Total "Somewhat Satisfied" Votes696
Total "Not Satisfied" Votes137
Total Rank Assessments115
Average Assessed Rank
5 kyu
Highest Assessed Rank
1 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • parceval Avatar
  • jhoffner Avatar
  • GiacomoSorbi Avatar
  • sajadtorkamani Avatar
  • jcsahnwaldt Avatar
  • MMMAAANNN Avatar
  • suic Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • kdmatrosov Avatar
  • clcraig Avatar
  • nirvanflame Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • tri@ Avatar
  • Just4FunCoder Avatar
  • yLaWy Avatar
  • KayleighWasTaken Avatar
Ad