g | x | w | all
Bytes Lang Time Link
010Uiua241008T020032Znoodle p
065Python 3.8 prerelease241007T115342ZJitse
040Wolfram Language Mathematica200911T223945Zatt
005Vyxal210421T081939ZWasif
314Pinecone210421T080846ZWasif
125Rust200911T172526ZTehPers
064R200911T074148ZCong Che
097LaTeX200911T081839ZSkillmon
023Pip200911T054932ZRazetime
077Python 3180606T093944ZDavin Mi
036Ruby pl180514T172511ZKirill L
011Stax180514T153630ZMulti
083PHP180513T214503Zmanasseh
087R180513T012255ZJayCe
056JavaScript ES6180512T142440ZArnauld
141Java 10180514T073152ZKevin Cr
083Scala180512T145141ZXavier G
122F# Mono180513T191004Zuser8000
020Retina 0.8.2180512T175650ZNeil
010Husk180513T153321Zბიმო
00905AB1E180513T143648ZEmigna
087Go180513T131515Zollien
043Groovy180513T091755ZMatias B
006V180512T164441Zuser4180
087Red180512T190725ZGalen Iv
063Python 3180512T183105ZDennis
054Röda180512T172957Zfergusq
055C gcc180512T150031Zbetseg
064Octave180512T160313ZStewie G
008Jelly180512T154019ZDennis
021sed 4.2.2 r180512T152057ZDigital
019Perl 6 p180512T153817Znwellnho
022APL Dyalog Classic180512T153558Zngn

Uiua, 10 bytes

⊜(⊂⊙⍜⊢⌵)⊸≠

Try it: Uiua pad

Explanation: Partition into chunks not equal to the character, reducing the chunks by joining after uppercasing the first character of the next.

Python 3.8 (pre-release), 65 bytes

f=lambda i,s,l=1:i and(l*i+i.upper())[:(x:=i[0]!=s)]+f(i[1:],s,x)

Try it online!

Not the shortest, but a different (recursive) solution

Wolfram Language (Mathematica), 45 40 bytes

StringReplace[#..~~c_|"":>Capitalize@c]&

Try it online!

Input [c][s].

Vyxal, 5 bytes

/ḣǐJṅ

Try it Online!

Pinecone, 314 bytes

s:String.input;p:String.input;k:IntArray:s.len;k.set:0,-1;o:"";n:1;i:0|i<s.len|i:i+1@((s.sub:i,i+1)=p?(k.set:n,i;n:n+1))k.set:n,s.len;i:1|i<n+1|i:i+1@(x:k.get:i-1;y:k.get:i;x:x+1;j:s.sub:x,y;e:1|e<256|e:e+1@((j.sub:0,1)=e.ascii?(e<96?(o:o+(e.ascii)+(j.sub:1,(j.len)))|(o:o+(e-32).ascii+(j.sub:1,(j.len))))))print:o

This was extremely fun....

Rust, 130 125 bytes

|s,c|(|mut u|s.chars().flat_map(|x|if x==c{u=1;vec![]}else if u>0{u=0;x.to_uppercase().collect()}else{vec![x]}).collect())(0)

Try it online!

-5 bytes thanks to Aiden4

So Rust has no built-in support for regular expressions or title case, and the uppercase function can return multiple characters... On the plus side, this works for non-ASCII encodings :)

R, 64 bytes

Pure regular expression solution using https://www.regular-expressions.info/replacecase.html. Unfortunately separators can be underscores so I couldn't use \w to capture letters. Improved version taking advantage of gsub's ignore.case parameter to save on [a-zA-Z]. Correction thanks to https://codegolf.stackexchange.com/users/95126/dominic-van-essen, who has a 25% shorter solution in the comments.

function(s,c)gsub('[^a-z]([a-z]?)([a-z]*)','\\U\\1\\E\\2',s,T,T)

Try it online!

https://codegolf.stackexchange.com/users/95126/dominic-van-essen 's solution, with an extra character removed (by using ? for optional):

R, 47 bytes

function(s,c)gsub("[^a-z]+(.)?","\\U\\1",s,T,T)

Try it online!

LaTeX, 97 bytes

The function

\def~#1#2{{\seq_set_split:Nnn~{#2}{#1}\seq_map_function:NN~"}}\def"{\let"\text_titlecase_first:n}

Complete document with test cases

\documentclass[preview,border=3.14]{standalone}

\ExplSyntaxOn
\catcode`\~13
\catcode`\"13

\def~#1#2{{\seq_set_split:Nnn~{#2}{#1}\seq_map_function:NN~"}}\def"{\let"\text_titlecase_first:n}

\ExplSyntaxOff

\begin{document}
~{Hello_world}_

~{me,no,like},

~{you-got-it}-

~{Am^I^clear}^

~{go!full!caps}!

~{weird&but&tRue}&

~{ProbleM1fixed1no}1

~{!prob!!lem!s!Olved!!}!
\end{document}

Results (in PDF)

enter image description here

Pip, 23 bytes

Ya^by@0AL(UC@_.@>_M@>y)

might be shorter with regex substitution.

Try it online!

Python 3, 77 bytes

o=[]
for x in s.split(c): o.append(chr(ord(x[0])-32)+x[1:])
print(''.join(o))

Try it online!

This assumes that the string is ASCII encoded and assumes that s and c are preloaded variables containing the input.

for x in s.split(x)       #loop through items in the string s split by x
    o.append(             #add the following to c
        chr(              #turn the following number into a character
            ord(          #turn the following character into a number
                x[0]      #the first character in string x
            )-32          #subtract 32 from this number
        +x[1:]            #add everything past and including the second character in string x

This solution works on the fact that in ASCII encoding, lowercase letters are positioned 32 entries after capitalised letters

Edit: i just realised that this also capitalises the first character in the string, which it shouldn't. but i'm quite proud of my nonsense, so i'll leave this up if that's allowed

Ruby -pl, 36 bytes

$_.gsub!(/[^a-z]+(.|$)/i){$1.upcase}

Try it online!

Takes only the string without second argument. Uses the block version of gsub! method because with common gsub! x,y syntax $1 is not readily filled with match data. |$ in regex is necessary for the test case with separator in the end.

Stax, 11 bytes

óKo{cplòüö\

Run and debug it

Explanation

/BsF1:/s^s|dl                 # Full Program, unpacked, Implicit Input
/                             # Split on substrings (Split input with symbol to split on)
 B                            # Remove first element from array. Push the tail of the array, then the removed element.
  s                           # Swap first two elements of stack
   F                          # Start for loop
    1:/                       # Split array at index; push both parts.
       s^s                    # Swap first two elements of stack, capitalize character, swap first two elements 
         |dl                  # Get length of stack, listify that amount (entire stack), implicit output of array

There's a few parts I would really like to fix somehow. I can get it down to about 8 bytes, but it fails on the last test case >.<

PHP, 91 83 bytes

$a=explode($argv[2],$argv[1]);echo array_shift($a);foreach($a as$i)echo ucfirst($i);

Run with -r. Was 2 bytes shorter using split instead of explode, but ^ test fails due to regex.

-8 thanks to Med

R, 87 bytes

g<-function(s,x,z=strsplit(s,x,T)[[1]])cat(z[1],capwords(z[-1]),sep="")
example(chartr)

Try it online!

Uses this trick can can not be properly executed in TIO so I simulated it.

We need the T otherwise one of the test cases fails.

JavaScript (ES6), 58 56 bytes

Saved 2 bytes thanks to @l4m2 / @Downgoat

Takes input in currying syntax (s)(c).

s=>c=>s.replace(u=/./g,x=>u=x==c?'':u?x:x.toUpperCase())

Try it online!

Commented

s => c =>                  // given s and c
  s.replace(u = /./g, x => // initialize u to a RegExp; replace each character x in s with,
    u =                    // and update u to:
      x == c ?             //   if x is the separator:
        ''                 //     an empty string
      :                    //   else:
        u ?                //     if u is not an empty string:
          x                //       x unchanged
        :                  //     else:
          x.toUpperCase()  //       x capitalized
  )                        // end of replace()

Java 10, 141 bytes

s->c->{var r=s.split("\\"+c);var r=a[0],t;for(int i=0;++i<a.length;r+=t.isEmpty()?"":(char)(t.charAt(0)&~32)+t.substring(1))t=a[i];return r;}

Try it online.

Explanation:

s->c->{                    // Method with String and character parameters and String return-type
  var r=s.split("\\"+c);   //  Split String by character (with potential regex char)
  var r=a[0],              //  Result-String, starting at the first item
      t;                   //  Temp-String to reduce bytes
  for(int i=0;++i<a.length;//  Loop in the range [1, length_of_array)
      r+=                  //    After every iteration: append the result-String with:
         t.isEmpty()?      //     If the current item empty:
          ""               //      Append nothing
         :                 //     Else:
          (char)(t.charAt(0)&~32)
                           //      Capitalize the first character
          +t.substring(1)) //     And append the other characters as is
    t=a[i];                //   Set `t` to the current String-item of the array
  return r;}               //  Return the result-String

Scala, 83 bytes

def f(s:String)={val w=s.split("[^a-zA-Z]");w(0)+w.tail.map(_.capitalize).mkString}

Try it online!

Explanation:

def f(s: String) = {                        // takes a String "s" as input
  val w = s.split("[^a-zA-Z]");             // split on non-alpha chars
  w(0) + w.tail.map(_.capitalize).mkString  // upper case first letter of all words except first one and join array into a String
}                                           //

F# (Mono), 122 bytes

let f(s:string)c=s|>Seq.mapi(fun i x->if i>0&&s.[i-1]=c then Char.ToUpper(x)else x)|>Seq.where((<>)c)|>Seq.toArray|>String

Try it online!

Retina 0.8.2, 20 bytes

T`lLp`LL_`[\W\d_]+.?

Try it online! Takes the string only, separator optional. All non-alphabetic characters are deleted but any following alphabetic character is uppercased. Previous 34-byte version accepted arbitrary input:

T`l`L`(?=.*(.)$)\1+.
(?=.*(.)$)\1

Try it online! Link includes test suite. Assumes the input consists of the string and character concatenated together. Explanation: The first stage transliterates all characters immediately following occurrences of the end character from lower to upper case and the second stage then deletes all occurrences of the end character.

For both solutions, using a right-to-left match instead of a + also works.

Husk, 10 bytes

ΣΓ·:mΓo:ax

Try it online!

Explanation

ΣΓ·:mΓ(:a)x  -- example inputs: 'x' "abxbcxcdxdex"
          x  -- split on character: ["ab","bc","cd","de"]
 Γ           -- pattern match (x = head) (xs = tail) and do..
  ·:         -- | construct list (x:xs) but with the second argument do..
    m        -- | | map (eg. "bc")
     Γ(  )   -- | | | pattern match on first character
      ( a)   -- | | | | upper-case it
      (: )   -- | | | | and join again
             -- | | | : "Bc"
             -- | | : ["Bc","Cd","De"]
             -- : ["ab","Bc","Cd","De"]
Σ            -- concatenate: "abBcCdDe"

05AB1E, 9 bytes

¡ćsvyćusJ

Try it online!

Explanation

¡           # split the string on the char
 ć          # extract the head of the resulting list
  s         # swap the head to the bottom of the stack
   vy       # for each string y in the rest of the list
     ću     # extract the head and capitalize it
       s    # swap it below the rest of the string
        J   # join everything to one string

Go, 138 92 87 bytes

Dropped 46 bytes thanks to @Dennis' title case idea.

func f(s,d string){p:=Split(s,d);Print(p[0]+Replace(Title(Join(p[1:]," "))," ","",-1))}

Try it online!

Groovy, 43 bytes, 45 bytes

s.replaceAll(/\$c(.)/){it[1].toUpperCase()}

Try it online. Test suite included excluding the last item as it lacks the separator char c.

V, 6 7 bytes

1 byte saved by not using argument

ÓÁˆ/õ±

Try it online!

The program takes in the text as input and the char as an argument.

Hexdump:

00000000: d3c1 882f f5b1                           .../..

This is a simple substitution. Uncompressed, it looks like the following

:s/\A(.)/\u\1/g

Perform a global substitution in which \A, a non-alphabetic character, followed by a character (.) is replaced with uppercased \u first capture group \1

Red, 87 bytes

func[s c][b: split s c prin b/1 foreach w next b[if w <>""[w/1: uppercase w/1 prin w]]]

Try it online!

Python 3, 63 bytes

lambda s,c:''.join(map(min,s,s[0]+s.title()[1:])).replace(c,'')

Try it online!

Röda, 57 54 bytes

-3 bytes thanks to Cows quack

{(_/`\Q$_`)|{pull;[upperCase(_[:1]),_1[1:]]if[#_1>0]}}

Try it online!

Explanation:

{
  (_/`\Q$_`)| /* Pull two strings and split the first with the second */
  {
    pull;                /* Pull one string and print it */
                         /* For each string _1 in the stream: */
                         /*   If _1 is not empty: */
    [                    /*     Print: */
      upperCase(_[:1]),  /*       The first character capitalized */
      _1[1:]             /*       The rest of characters */
    ]if[#_1>0]           /*   End if */
  }
}

C (gcc), 61 53 55 bytes

-8 bytes thanks to Dennis!

f(s,c)char*s;{for(;*s;putchar(*s++))if(*s==c)*++s&=95;}

Try it online!

Octave, 83, 66, 64 bytes

Saved 2 bytes thanks to Luis Mendo. upper instead of toupper.

@(s,c,k=upper(s(i=find(s==c)+1)))[strsplit({s(i)=k,s}{2},c){:}];

Try it online!

Wow, that's probably the messiest piece of Octave-code I've ever written! This uses two of the tricks posted in this tips question, namely Argument list, and cell arrays.

Explanation:

Argument list input:

@(s,c,k        % An anonymous function that may take three input variables, s, c, k
               % where the third argument has the default value:
 k=upper(s(i=find(s==c)+1))

k is here the first character in s after each separator c, converted to upper case. The index of each capitalized character is stored in i.

Cell array body:

We create a cell array with two elements, one were we say that all i'th characters should be substituted by its counterpart in k, and the other one with s, that is now already updated. We index this using {2} so that we only get the whole, modified string back. This is fed to strsplit, which splits it into cells at the separator character. We convert it to a comma-separated list using {:}, and concatenates it back to a string using square brackets [].

Apologies if that didn't make any sense to you... It barely makes sense to me :P

Jelly, 8 bytes

Œt⁸1¦«⁸ḟ

Try it online!

How it works

Œt⁸1¦«⁸ḟ  Main link. Left argument: s (string). Right argument: c (character).

Œt        Title case; capitalize the first character of each word.
  ⁸1¦     Replace the first character of the result with the first character of s.
     «⁸   Take the character-wise minimum of the result and s.
          Note that uppercase letters have lower code points than lowercase ones.
       ḟ  Filterfalse; remove all occurrences of c.

sed 4.2.2 (-r), 21

s/[^a-z]+(.)?/\u\1/gi

I tried \W instead of [^a-z], but unfortunately that doesn't match _.

Try it online!

Perl 6 -p, 19 bytes

s:g[<:!L>(.)]=$0.uc

Try it online!

APL (Dyalog Classic), 22 bytes

{⍵~⍨1(819⌶@(⍵=¯1⌽⊢))⍺}

Try it online!