[Question]
  [
Your challenge: Write a function that takes a string `s`, a character `c`, and finds the length of the longest run of `c` in `s`. The length of the run will be `l`.
**Rules**:
* If `s` is of length 0 or `c` is empty, `l` should be 0.
* If there are no instances of `c` in `s`, `l` should be 0.
* [Standard loopholes](https://codegolf.meta.stackexchange.com/q/1061/61563) and [Standard I/O Rules](https://codegolf.meta.stackexchange.com/q/2447/61563) apply.
* No matter where in `s` the run of `c`s is located, `l` should be the same.
* Any printable ASCII characters can appear in `s` and `c`.
**Test cases**:
```
s,c --> l
"Hello, World!",'l'  -->  2
"Foobar",'o'         -->  2
"abcdef",'e'         -->  1
"three   spaces",' ' -->  3
"xxx xxxx xx",'x'    -->  4
"xxxx xx xxx",'x'    -->  4
"",'a'               -->  0
"anything",''        -->  0
```
**Winner**:
As with [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") the shortest answer in each language wins.
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
### Code:
```
SQγOM
```
Uses the **05AB1E** encoding. [Try it online!](https://tio.run/##MzBNTDJM/f8/OPDcZn/f//89UnNy8nUUwvOLclIUuXIA "05AB1E – Try It Online")
### Explanation:
```
SQ      # Check for each character if it is equal to the second input
  γ     # Split the list of zeros and ones into groups
   O    # Sum each array in the arrays
    M   # Get the maximum
```
[Answer]
# Mathematica, 35 bytes
```
Max[Tr/@Split@Boole@Thread[#==#2]]&
```
Pure function taking a list of characters and another character as input and returning a nonnegative integer. Improved upon my first effort using [Adnan's observation](https://codegolf.stackexchange.com/a/125385/56178) (go upvote!) that one should test for equaling the special character before splitting the array.
`Thread[#==#2]` checks whether each input character in the first argument equals the character given as the second argument. `Boole` converts the resulting `True`s and `False`s to `1`s and `0`s. `Split` splits the list into runs of consecutive elements; `Tr/@` sums each sublist, and `Max` finds the winner. (Because of how `Max` works, if the first argument is the empty list, then this function returns `-∞`. So, you know, don't do that.)
## first submission (51 bytes)
```
Max[Split@#/.a:{c_String..}:>Boole[c==#2]Length@a]&
```
`Split@#` splits the input into runs of consecutive characters, such as `{{"t"}, {"h"}, {"r"}, {"e", "e"}, {" ", " ", " "}, {"s"}, {"p"}, {"a"}, {"c"}, {"e"}, {"s"}}` for the fourth test case. `/.a:{c_String..}:>` replaces each subexpression `a` that is a list of a repeated character `c` by `Length@a` multiplied by `Boole[c==#2]`, which is `1` if `c` equals the input character and `0` otherwise. Then `Max` extracts the answer.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 20 18 15 bytes
```
fV+Vî+)ª0)n o l
```
[Try it online!](https://tio.run/##y0osKPn/Py1MO@zwOm3NQ6sMNPMU8hVy/v9XKskoSk1VUFAoLkhMTi1W0lFXUAcA "Japt – Try It Online")
Saved 5 bytes thanks to obarakon and ETHproductions
[Answer]
# [Python](https://docs.python.org/2/), 38 bytes
```
f=lambda s,c:+(c in s)and-~f(s,c+c[0])
```
[Try it online!](https://tio.run/##LcyxCsIwEIDhuX2Ks0sbGkEdC13FN3AQhzS50kBMQhIxLr56vFqXO/6P4/w7Lc6eSplHIx6TEhC5HPpOgrYQmbBq/5k7sl7eDndWXos2CMehrshGbf0zdayufNA2we@QcXoBsjQXNMZxuLpg1K7hrWnr5uzcJAKFoxCTVDhTIEVaAiIARC8kRkIgzDlD3gZJ3mStVf9CS7Rf "Python 2 – Try It Online")
Dennis saved 3 bytes by updating `c` to a string of duplicated characters rather than recursively updating a number to multiply `c` by.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~11~~ 6 bytes
-5 bytes thanks to [carusocomputing](https://codegolf.stackexchange.com/users/59376/carusocomputing)
```
γvy²¢M
```
[Try it online!](https://tio.run/##MzBNTDJM/f//3OayykNrDm0KzEyvNfD9/78koyg1VUFBobggMTm1mEsBAA "05AB1E – Try It Online")
```
γ      # split into chunks of consecutive equal elements
 vy    # For each chunk...
   ²¢  #  Count the number of input characters in this chunk
     M #  Push the largest count so far
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
=ĠṠG
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCI9xKDhuaBHIiwiIiwiW1wieFwiLFwieFwiLFwieFwiLFwiIFwiLFwieFwiLFwieFwiLFwiIFwiLFwieFwiLFwieFwiLFwieFwiXVxueCJd)
```
=    # Is each character of the string equal to the character?
     # Produces a list of 1s and 0s
 Ġ   # Group consecutive items
  Ṡ  # Sum each - groups of 1s become their length, groups of 0 become 0 
   G # Find the maximum
```
[Answer]
## Haskell, ~~43~~ 39 bytes
```
f c=maximum.scanl(\n k->sum[n+1|c==k])0
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00h2TY3sSIztzRXrzg5MS9HIyZPIVvXrrg0NzpP27Am2dY2O1bT4H9uYmaegq1CSj6XgkJBUWZeiYKKQpqCerK6glJycrJCMoRQwpTFIpSYlJySmqb0HwA "Haskell – Try It Online")
Run through the string and replace the current char with a counter that is increased whenever it equals `c` or reset to `0` if not. Take the maximum of the list.
Thanks to @xnor for 4 bytes.
[Answer]
# C# ~~116~~ 115 bytes
My first code golf
Edited because initial submission was a snippet and was missing required namespace for regex
Edit#2 complete rewrite to support characters with special regex meanings
~~using System.Linq;s=>c=>System.Text.RegularExpressions.Regex.Replace(s,"[^"+c+"]",++c+"").Split(c).Max(x=>x.Length);~~
```
using System.Linq;s=>c=>{var r=(char)(c-1);return string.Join("",s.Select(x=>x==c?c:r)).Split(r).Max(x=>x.Length)};
```
[Answer]
# JavaScript (ES6), ~~54~~ ~~53~~ 51 bytes
*-2 bytes thanks to @Neil*  
*-1 byte thanks to @apsillers*
```
s=>c=>[...s].map(x=>j=(i=x==c&&i+1)>j?i:j,i=j=0)&&j
```
Takes input in currying syntax: `f("foobar")("o")`.
## Test Snippet
```
f=
s=>c=>[...s].map(x=>j=(i=x==c&&i+1)>j?i:j,i=j=0)&&j
```
```
String: <input id=I> Letter: <input id=J maxlength=1 size=1> <button onclick='O.innerHTML+=`f("${I.value}")("${J.value}") = ${f(I.value)(J.value)}\n`'>Run</button><pre id="O"></pre>
```
### Another option using `eval` and `for` (54 bytes)
```
s=>c=>eval("i=j=0;for(x of s)i=x==c&&i+1,i>j?j=i:0;j")
```
### Old Answer using Regex (85 bytes)
```
s=>c=>c?Math.max(...s.match(eval(`/${/\w/.test(c)?c:"\\"+c}*/g`)).map(x=>x.length)):0
```
[Answer]
## JavaScript (Firefox 30-57), ~~75~~ 72 bytes
```
(s,c)=>Math.max(0,...(for(s of s.split(/((.)\2*)/))if(s[0]==c)s.length))
```
ES6 compatible snippet:
```
f=
(s,c)=>Math.max(0,...s.split(/((.)\2*)/).filter(s=>s[0]==c).map(s=>s.length))
```
```
<div oninput=o.textContent=f(s.value,c.value)><input id=s><input id=c maxlength=1 size=1><pre id=o>0
```
`split` returns a bunch of empty strings and single characters as well as the runs but this doesn't affect the result.
[Answer]
# [Micro](http://esolangs.org/wiki/Micro), 112 bytes
```
{T l m 1+:Q # T Q T l~:r}:Z{T[0]+}:X
{i s m:n
n p = if(Z,X)
i L=if(,a)}:a
0\\:C:s:i"":p"":n[0]:T
s l:L
a
T l m:\
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 63 bytes
```
i;m;f(s,c)char*s;{for(i=m=0;*s;s++)*s^c?m=m>i?m:i,i=0:i++;s=m;}
```
[Try it online!](https://tio.run/##ZY7BisIwEIbvPsVspLSxKXg2RE@77H2FvZSFOKY60DSSeAiIz16netniHAb@7xtmBpsT4jiS9rqrkkKJZxtXSd@6ECsy3qw1p1TXcpX@cOeN39LOb0iRWW@ornUyXt/H5dF1NDjYf/7sn2vgEmm4dpVoRZFaoaAssISm2QIU1A4MkgJU8DoqF97SUMnbArieS8S36/ug4DfE/vghVNmXUv/TXyEcbGQe5twekH9h7ub8eo7OcUoXiy6xh7nPOUN@NZb5TU5iGniXTOxE7uMD "C (gcc) – Try It Online")
[Answer]
# [Perl 6](https://perl6.org), ~~45 43~~ 42 bytes
```
->$_,$c {$c&&$_??.comb(/$c+/)».chars.max!!0}
```
[Test it](https://tio.run/##ZY9da8IwFIbv8yuOpdgWk7ovvFhRt4uOwTa92NgYFCRNj1OoTWnqqDh/2e72x7pTde4rgZC8z3vOe5JjkfbqpUF47fkqYIsVtJVOEPq1GNgTbitY26rdtifDoa/0Ina7tup0vY93X81kYfyFrFqto01NhRclmhL6kM4zNK5HKD@HNQNo2t@NRzfhs7gPQzEai/Dx8jYg8tZcXN8sY1O6jhADh9P2PA72hG1YU/hATQOWpzKDzjYhYFNd7MPEANzI8EjxCKscVYkJjxI0ytsGzw00n3ENV9Ty4IDGwTa1dY1pqjk86SJNWhZ3UgeAhgA4YdaV1rEsSNQk7tcXk7FKcEoM/7BjZpWzApHeJpcKDXnA2bFTZlVVBdXuIFA5h7qzLWv0hv9jJMjvpB95RzRLtipn8@yFPM5v9gk "Perl 6 – Try It Online")
```
->$_,$c {$c&&$_??.comb(/$c+/).max.chars!!0}
```
[Test it](https://tio.run/##ZY9da8IwFIbv8yuOpdgW0@o@8GJF3S46Btv0YmNjUJA2PU6hNqWpI6L@9u5EnftKICTv857znpRY5f1mpRA@@oEI2XINbSEzhEHjD@0ptwVsbNFu29PRKBBymbpdW3S6XrBMdCDmSaVard6uobLrGlUNA8gXBSrXGMor2DAA0/xxMr6P3vynKPLHEz96uXkIiWzNxQ3UKlW16/j@0OG0PY@DPWU7ZgqfqWnIyjwpoLNPCNlMVscwfwhurHgseIy6RFFjxuMMlfD2wQsF5iuu4oJanhxgHGzXWHeY55LDq6zyrGVxJ3cAaAiAc2bdSpkmFYmSxOP6YkkqMpwRwz/sjFn1vEKktyoTgYo84BzYBbO01qAPBwHtnOou98zohv9jJCTfST/yejRLsa7ni@KdPM5v9gk "Perl 6 – Try It Online")
```
->$_,$c {$c&$_??.comb(/$c+/).max.chars!!0}
```
[Test it](https://tio.run/##ZY9da8IwFIbv8yuOpZgW0@o@8GJF3S46Btv0YmNjUJA2PU6hNqWpo6L@9u5EnftKICTv857znhRYZv1mpRE@@r4M2HINbalShEHjDe2psCVsbNm2p6ORL9Uycbq27HRdfxnXvpzHpW61eruGqq4r1BUMIFvkqB1jKK5gwwBM78fJ@D58857C0BtPvPDl5iEgsjUXx9erRFcO97whF7RdV4A9ZTtmCp@pacCKLM6hs08I2EyVxzBvCE6kRSRFhHWBssJURClq6e6DFxrMTxwtJLU8OcA42K6x7jDLlIBXVWZpyxI84wA0BMA5s26VSuKSREXicX2xOJEpzojhH3bGrGpeItJbF7FETR7gB3bBrLquoT4cBGp@qrvcM6Mb/o@REH8n/cjr0Sz5upov8nfy8N/sEw "Perl 6 – Try It Online")
## Expanded:
```
-> $_, $c {       # pointy block lambda
    $c & $_       # AND junction of $c and $_
                  #   empty $c would run forever
                  #   empty $_ would return 4 ( "-Inf".chars )
  ??              # if True (neither are empty)
    .comb(/$c+/)  # find all the substrings
    .max          # find the max
    .chars        # get the length
  !!              # if False (either is empty)
    0             # return 0
}
```
[Answer]
# JavaScript, ES6, 52
Recursive solution that treats the string input as an array (note: the initial input is still a string) and consumes left-to-right in character `C`:
```
f=([C,...s],c,t=0,T=0)=>C?f(s,c,C==c&&++t,t>T?t:T):T
```
Tracks current run in `t` and global best in `T`.
Explanation:
```
f=            // function is stored in `f` (for recursion)
  ([C,...s],  // turn input string in first-char `C` and the rest in `s`
   c,         // argument `c` to search for
   t=0,T=0)   // current total `t`, best total `T`
     =>
        C?             // if there is still any char left in the string
          f(s,c,       // recursively call `f`
            C==c&&++t, // increment `t` if char is match, or set `t` to `false`
            t>T?t:T)   // set global `T` to max of `t` and `T`
          :T           // when string is depleted, return `T`
```
Setting `t` to `false` on non-matches works because whenever `t` is incremented, `false` is treated as `0` (i.e., `false + 1` is `1`), and `false` will never compare grater than any value in global-max `T`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
=ŒgṀS
```
This is a dyadic link/function that takes a string and a character. Note that it cannot work as a full program, as input from command-line arguments uses Python syntax, and Python – unlike Jelly – does not distinguish singleton strings from characters.
[Try it online!](https://tio.run/##Tc2xCsIwEAbg3af43YM@gau4FxTHa3u1lWBKWiXdio/grLOLo6DiKD5I@yKxqQEd7nJ8P5dbs5SVtZP3YdU86sA2zyvm7f6C13nsniXQ3G9tfUSQy6wElZDZhhPmuBDgHUkwRWmPAprjbcS9CBSck6aSEVa/nZG13Wez7qoSWCgt42Fbn0RXctAFU6V0SNqTckRhFHPihZ2UqWYGUOQUceETuMQYA/Ntno1nRy76Zz/TBw "Jelly – Try It Online")
### How it works
```
=ŒgṀS  Main link. Left argument: s (string). Right argument: c (character)
=      Compare all characters in s with c, yielding 1 for c and 0 otherwise.
 Œg    Group adjacent, equal Booleans in the resulting array.
   Ṁ   Take the maximum. Note that any array of 1's will be greater than any array
       of 0's, while two arrays of the same Booleans are compared by length.
    S  Take the sum, yielding the length for an array of 1's and 0 otherwise.
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 25 bytes
```
(.).*?(\1*)(?!.+\2).*
$.2
```
[Try it online!](https://tio.run/##K0otycxL/P9fQ09TT8teI8ZQS1PDXlFPO8YIyOdS0TP6/z/fLT8/KbEIAA "Retina – Try It Online")
The first character is the character to be checked.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~18~~ 11 bytes
Requires swapping `⊂` with `⊆` in Version 16.0 or having `⎕ML←3` (default on many systems).
```
⌈/0,≢¨⊂⍨⎕=⎕
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qr8@jtgnGXI862n3y84AiPR36BjqPOhcdWvGoq@lR7wqgElsg/g9U8F8BDEDquNQ9UnNy8nUUwvOLclIU1bnUc9S5kKXd8vOTEouA4vmo4olJySmpaUDxVFTxkoyi1FQgr7ggMTm1GCivgCpfUVGhUAEhgJIVGJIgCZACTEmgSCKaG/IqSzIy89KBMuoA "APL (Dyalog Unicode) – Try It Online")
`⎕=⎕` Boolean for equality between two inputs
`⊂⍨` self-partition (begin partitions where a non-zero element is greater than its predecessor)
`≢¨` tally each
`0,` prepend a zero (for the empty-input cases)
`⌈/` max of those
---
Old solution
Prompts first for *s*, then for *c*
```
⌈/0,(⎕,¨'+')⎕S 1⊢⎕
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKPdJz8PSPd06BvoaDzqm6pzaIW6tromkBWsYPioaxGQAVL1XwEMQIq51D1Sc3LydRTC84tyUhTVudRz1LmQpd3y85MSi4Di@ajiiUnJKalpQPFUVPGSjKLUVCCvuCAxObUYKK@AKl9RUaFQASGAkhUYkiAJkAJMSaBIIpob8ipLMjLz0oEy6gA "APL (Dyalog Unicode) – Try It Online")
`⎕` prompt for s
`⊢` for that
`(`…`)⎕S 1` PCRE **S**earch for the lengths of occurrences of
 `'+'` a plus symbol (meaning one or more)
 `,¨`  appended to each of the elements of
 `⎕` the prompted-for *c*
`0,` prepend a zero (for the empty-input cases)
`⌈/` max of those
*c* must be given as a 1-element vector of an enclosed string if it needs escaping.
[Answer]
# PHP, ~~70~~ 67 bytes
three versions:
```
while(~$c=$argv[1][$i++])$x=max($x,$n=($c==$argv[2])*++$n);echo+$x;
while(~$c=$argv[1][$i++])$x=max($x,$n=$c==$argv[2]?++$n:0);echo+$x;
for(;++$n&&~$c=$argv[1][$i++];)$x=max($x,$n*=$c==$argv[2]);echo+$x;
```
takes input from command line arguments; run with `-r` or [test them online](http://sandbox.onlinephpfunctions.com/code/6e28c32804921c118e088c07cc97afb6c03f9dde).
[Answer]
# [PHP](https://php.net/), 70 bytes
```
for(;~$c=$argv[1][$i++];)$r[]=$argv[2]==$c?++$n:$n=0;echo$r?max($r):0;
```
[Try it online!](https://tio.run/##LcqxCsMgEADQvZ8hB0kwgbRjrqcfIg4i0etQlRtCp/51ZgOl6@M1bv1pG7cbBMkHObWoWaWUsxhjMrOahzB47KnKiF@I9Hvu7h28tPY4gTj/x4cngmi1hrJBoRX3yBXEvsNnBJm2FXs/S11iiLxf "PHP – Try It Online")
# [PHP](https://php.net/), 75 bytes
```
for(;~$s=substr($argv[1],$i++);)$r[]=strspn($s,$argv[2]);echo max($r?:[0]);
```
[Try it online!](https://tio.run/##JYqxCsIwEEB3v6KEgyY0BXU0hn5IyBBDNQ42x53KTf61cyx2ecN7Dwu284QFd5Do9vZBjcoqEelkg7K99NG1ayXtPsCeXxd@kv7v4RAt3IfBOAMUol8D46KB7ZaP0bg5l9o9kmig6RT2q2ntu9Qxp1zmHw "PHP – Try It Online")
# [PHP](https://php.net/), 83 bytes
```
<?=@preg_match_all("<".preg_quote($argv[2])."+>",$argv[1],$t)?strlen(max($t[0])):0;
```
[Try it online!](https://tio.run/##JYzLDoMgFAX3foW5kggpPuqyIvY/KDHEEFmgUkub@@NdW2PPbiaZE1zYRR9cSIjZpk@noAAOiJhmWVWhPIb4EAJTROC5zHWb9PJIunvY7DTMJo5uMN5TEFCe6vleo6XnnWo0K@Eigf/xqjmJrH/FzduFzgYpiarWjN3qdt@/y1qMZnT2Bw "PHP – Try It Online")
+8 Bytes to avoid `@` 
```
<?=($a=$argv[2])&&preg_match_all("<".preg_quote($a)."+>",$argv[1],$t)?strlen(max($t[0])):0;
```
[Answer]
# JavaScript (ES6), ~~47~~ ~~40~~ 38 bytes
(Saved 7 bytes thanks to @Neil, and 2 bytes thanks to @HermanLauenstein.)
```
s=>g=c=>c&&s.includes(c)?1+g(c+c[0]):0
```
**Explanation:**
Recursively searches for a longer run until none is found.
**Snippet:**
```
let f=
s=>g=c=>c&&s.includes(c)?1+g(c+c[0]):0
console.log(f('Hello, World!')('l'  ));  //2
console.log(f('Foobar')('o'         ));  //2
console.log(f('abcdef')('e'         ));  //1
console.log(f('three   spaces')(' ' ));  //3
console.log(f('xxx xxxx xx')('x'    ));  //4
console.log(f('xxxx xx xxx')('x'    ));  //4
console.log(f('')('a'               ));  //0
console.log(f('anything')(''        ));  //0
```
[Answer]
# Jelly, ~~10~~ 9 bytes
```
f⁴L
ŒgÇ€Ṁ
```
Explanation:
```
f⁴L
f⁴      -Filter by the character argument.
  L     -Return Length of filtered String.
ŒgÇ€»/
Œg      -Group string by runs of characters.
  Ç€    -Run above function on each group.
    Ṁ   -Return the largest in the list.
```
[Try it online!](https://tio.run/##y0rNyan8/z/tUeMWH66jk9IPtz9qWvNwZ8P///8zgFL5CuX5RTkpiv9zAA "Jelly – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 71 bytes
```
f=lambda s,c,m=0,k=0:s and f(s[1:],c,-~m*(s[0]==c),max(m,k))or max(m,k)
```
[Try it online!](https://tio.run/##NY6xDoIwFEV3v@LJ0pY8DepG0t0/cGg6FChCaIG0HTAEf71WjC93uOcs982v0E3jLcaWG2WrRoHHGi0vcOBF6UGNDbTUi0spkz@9bZ6gkJzXDK1aqMWBscnBv8c2QdA@QD@CEOSujZkQHpMzzZEgMUQiCKKqutFt4ufO2ZIO9iwZkuUnQ@e0BgA/q1r75IFIWR5gdv0YaLaW19sG65ad06ZVgfrg6HeaYXo53xtj8QM "Python 3 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 66 bytes
```
import Data.List
((maximum.(0:).map length).).(.group).filter.elem
```
[Try it online!](https://tio.run/##FcKxCgIxDADQ3a8It1w7GJyF2xz1I8KRXoNNG9oc@OPOFR8v03hzKXOKWusOD3LCpwy/pC0EpY/oqRhu94hKBoXr4TlixIBHb6dFTFKcO3JhnUpSYQPrUh1CgnWssLxkjH8zWeL81nbdac/8Aw "Haskell – Try It Online")
A slightly easier to read version - not pointfree:
```
f c s = maximum (0:(map length (filter (elem c) (group s))))
```
Groups the string by letter, then filters by those groups that contain the right character, then finds the lengths, appends 0 to the list of lengths in case it doesn't appear, and finally finds the maximum value.
[Answer]
# Mathematica, 109 bytes
```
(s=Differences[First/@StringPosition[#,#2]];k=t=0;Table[If[s[[i]]==1,t++;If[k<t,k=t],t=0],{i,Length@s}];k+1)&
```
  
**input** 
> 
> ["xxx xxxx xx","x"]
> 
> 
> 
[Answer]
# [Python 2](https://docs.python.org/2/), 69 bytes
```
lambda s,c:c and max(map(len,re.findall(c+'+',s))or[0])or 0
import re
```
[Try it online!](https://tio.run/##XZDBbsMgDEDvfIV3IlHRlPVYqdepf9BDhiYHTItEAAEH9vUZbJOy1gfLfs@SZcevcg/@uJnzx@ZwXTRCFuqkAL2GFeuwYhwceZHo1Viv0blBHfiBizyOIc2TbBkmZtcYUoFEW6FcPhVmynCGmUGLmV/IuSDgGpLTL1wAd1yKP/cewoKpw7BDXJQm0yHtsNwTUatyREW5S9hlrRXqb@qmPphOu30yvcV/S337hvW3jrlkkjHTjrNgPexXnX6GY7K@gBls@4AAO7/JcfsG "Python 2 – Try It Online")
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~20~~ ~~19~~ ~~18~~ 16 bytes
```
0q~e`f{~@=*}$+W=
```
[Try it online!](https://tio.run/##S85KzP3/36CwLjUhrbrOwVarVkU73Pb/f/UcBSWP1JycfB2F8PyinBRFJQA "CJam – Try It Online")
### Explanation
```
0                 e# Push 0. We'll need it later.
 q~               e# Read and eval input. Pushes c and s to the stack.
   e`             e# Run-length encode s: turns it into an array of [length, char] pairs.
     f{           e# Map over these pairs using c an extra parameter:
       ~          e#  Dump the pair to the stack.
        @=        e#  Bring c to the top, check equality with the char, pushing 0 or 1.
          *       e#  Multiply the length by the result.
           }      e# (end map)
            $     e# Sort the resulting list in ascending order.
             +    e# Prepend the 0 from before, in case it's empty.
              W=  e# Get the last element.
```
[Answer]
# Excel, 56 bytes
```
{=MAX(IFERROR(FIND(REPT(A2,ROW(A:A)),A1)^0*ROW(A:A),0))}
```
`s` should be input to `A1`.  
`c` should be input to `A2`.  
Formula must be an array formula (`Ctrl`+`Shift`+`Enter`) which adds curly brackets `{ }`.
Technically, this can only handle where the longest run is less than 1,048,576 (which is 2^20) because that's how rows the current Excel will let you have in a worksheet. Since it loads the million+ values into memory whenever it recalculates, this is not a *fast* formula.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 15 bytes
```
0i0v=dfd1L)0hX>
```
[Try it online!](https://tio.run/##y00syfn/3yDToMw2JS3F0EfTICPC7v9/dY/UnJx8hfD8opwUdS71HHUA "MATL – Try It Online")
The basic algorithm is very simple (no use of split!), but I had to throw in `0i0v` and `0h` to allow for the edge cases. Still, I thought the approach was nice, and perhaps I can still find another technique to handle the edge cases: the algorithm finds the longest run in the middle of a string just fine, but not for single characters or empty strings; I'm still testing if I can 'pad' the variables at better places for better results.
```
0i0v % Prepends and appends a zero to the (implicit) input.
   = % Element-wise equality with the desired char (implicit input)
   d % Pairwise difference. Results in a 1 at the start of a run, and -1 at the end.
   f % Get indices of 1's and -1's.
   d % Difference to get length of the runs (as well as length of non-runs)
 1L) % Only select runs, throw out non-runs. We now have an array of all run lengths.
  0h % 'Find' (`f`) returns empty if no run is found, so append a zero to the previous array.
  X> % Maximum value.
```
Does not work on empty `c`. Then again, I suppose each string contains an infinite run of empty strings between each character :)
[Answer]
# [R](https://www.r-project.org/), ~~66~~ 58 bytes
*-8 bytes thanks to BLT and MickyT*
```
function(s,c)max((r=rle(el(strsplit(s,''))))$l*(r$v==c),0)
```
returns an anonymous function. TIO has a 1-byte difference because `el` doesn't work there for inexplicable reasons.
[Try it online!](https://tio.run/##DchBCoAgEADAe6@oJWg3PNQDvPeDDuEhTEHYMlaLfm/ehpHidfHPZXOIFyZl6dw/RNHCDlOWdHPI9YeBtm02hqjnEaV/tbakJioeYXHMUbVrFD46UMBATe2qHaj8 "R – Try It Online")
[Answer]
# Java 8, ~~67~~ 65 bytes
```
s->c->{int t=0,m=0;for(char x:s)m=m>(t=x==c?t+1:0)?m:t;return m;}
```
-2 bytes thanks to *@OlivierGrégoire*
Takes input `s` as a `char[]`, and `c` as a `char`
**Explanation:**
[Try it here.](https://tio.run/##pdI9a8MwEAbgPb/imiU2dYS7xrVDKYR26JShQ5pBkeVEqT6MdA4yIb/dlalLJ1NDQQhxd3p4ETrTC12amutz@dkJVRuLcA410qCQpGo0Q2E02QyHbMYkdQ7eqNDXGYBDioLBT/uRnajd7ZPfwnMoUIbcJvCqkR@5LQqoIIfOLQu2LK5CI2CeJipPs8rYqBfAr1ysclVEmPs8Z2u8f1il8VqtMLMcG6tBZbcuCwHCqpuDDBmGKBcjSlAhXrRFK/Rxtwca91EBtq1DrohpkNShhVJHFaF1Ldto/sKlNAm8GyvLuzlB0wd/spa2URwPQwu5iOPsT2pjzIHaMcNMMuiBlbwaM/gkA0@W8zDjasq4G7NgkuW9B/@9jUF@KtQjPfY/aOw2nfa@usVT@B1jykc6MLfZrfsC)
```
s->c->{          // Method with char[] and char parameters and int return-type
  int t=0,       //  Temp counter-integer
      m=0;       //  Max integer
  for(char a:s)  //  Loop over the characters of the input
    m=m>(
     t=x==c?     //   If the current character equals the input-character:
      t+1        //    Raise `t` by 1
      :          //   Else:
       0)        //    Reset `t` to 0
    ?m:t;        //   If `t` is now larger than `m`, put `t` as new max into `m`
                 //  End of loop (implicit / single-line body)
  return m;      //  Return the resulting max
}                // End of method
```
]