[Question]
  [
**Story:**
The π was recently computed with accuracy to [100 trillions digits](https://cloud.google.com/blog/products/compute/calculating-100-trillion-digits-of-pi-on-google-cloud), but it is useless to us. We can't do accurate enough math, because rational numbers are too boring and so we don't know that much digits of them!
**Challenge:**
Your task will be to write program or function which takes string of digits including decimal separator and outputs next digit of this number. You can get next digit by knowing, that the input is composed out of two strings (ignoring the decimal separator) like this `abb`. For example the number `0.1818` is composed of string `a` which is `0` and `b` which is `18` and the output will be first digit of `b`, which is `1`. If there are multiple choices for string `b` you have to use longest one. The string `a` can be empty.
The decimal separator is guaranteed to be in every number and won't be first or last character of input. You can choose which decimal separator you want to support from following [characters](https://en.wikipedia.org/wiki/Decimal_separator): `.,·'`
**Testcases:**
| Input | a | b | Output |
| --- | --- | --- | --- |
| 0.1818 | 0 | 18 | 1 |
| 6.66 | 6 | 6 | 6 |
| 3.3 |  | 3 | 3 |
| 0.0526315789473684210526315789473684210 | 00 | 526315789473684210 | 5 |
| 37.0370 |  | 370 | 3 |
| 88.998899 |  | 8899 | 8 |
| 1657.7771657777 |  | 1657777 | 1 |
| 5.0000000 | 50 | 000 | 0 |
| 25885882588.588 |  | 2588588 | 2 |
| 9.99999 |  | 999 | 9 |
| 1.221122 | 12211 | 2 | 2 |
| 1.2112113211 | 121121132 | 1 | 1 |
 
  
[Answer]
# Regex (ECMAScript or better), ~~38~~ ~~34~~ 20 bytes
```
((.).*),?(.*)\1,?\3$
```
Uses `,` as the decimal separator. Returns its output as capture group `\2`.
[Try it on regex101](https://regex101.com/r/SDieAA/13) - ECMAScript (and can be switched to others)  
[Try it online!](https://tio.run/##bYvNToNAFIX38xQ0MeFOndL5KcwgQdI0Tdz4k1pX1gVph4oCJQP1p8atD@Aj@iI4aOLKk3vPufck30P6lDZrk9ftqKnzjTblrnrUr52JK/3sLPR2/lIDHOLT8bAD8LA3xCQB6ytGkpU46objA/ba3XVr8moL2GuKfK0hIKMJxlG2M5DFLIIiNjrdFHmlAeNBXO2LIspiit/yDAYZri3cAo7qfdu0Bopj1/n6@HTcvwbKuPDKtF3fg8E4gfKW3yW9nbgXl85serW8Wcxd/POdT5ezM4u@d5QwxRQKSBAgQQSihPo8EMyXKpxIEagJZ/80SEhChaRIKRKGSoUhYoEviZSyTyvkE/orxH2l7PRB7KLQImFPEM4Z47w/bDIm7H4D "JavaScript (SpiderMonkey) – Try It Online") - ECMAScript  
[Attempt This Online!](https://ato.pxeger.com/run?1=bVDBbtQwEBVXf4WxLK1deXfjpEmcmiiq2gCVYLcKy6mprGVxupGyu5GTnhBX7nDlUgnxB_wMPfZLmGQ5ISyP3_jNe6Oxv_9ot-3D47OPLzJIMHU4xWRO8Ay3zt4ZZ9tmvbFsMp-dZMZs101vNoddWzfWlazkuizm3UTgCUQFpLmzg2Df233fMWNeXr3JjeECSw4tobFG1cExWqeepk1agbxj71aXVwuu-SdcV4w2N13vGruHjE_lbZqSck84iLv7D1ABWnhiKrke1TW3m-1hkGgMXaVGGA8MJrTBT1--YeDHl-zW_WbLqBPgpztwj6qx1Ky73ljnYDD-PL0u8ldmsTR5USyLjOQDT84Y3WWs7jrbQ3bj3_JshDOyWOKL8-vV-yInfLy9PV9dvCZcf_7nuxjXP-_7aqp-MTbjsxMuMgZnKUVWBvRYevgLv796QiqpUCSiCAUiQJ7wQj8KZBir5DQOInXqy_8wKIiFF8QeUkokiVJJgmQUxiKO4wFhoVB4x4X8UCnYAwgIlIAlGRzC96X0_SEBlDKAOE72Bw "PHP – Attempt This Online") - PCRE2  
[Try it online!](https://tio.run/##bU5LasMwEN3rFMYIIpWJ0Se2pBiTQNc9QZJFSJTY4FhGdnBJ8LYH6BF7EVcmi276mDdvPsxjWjdY35W2rifsi523V/t5WK8bO5DtYiIkockbhQ0Jec9hs5d4Wmwhfne3tqrtOaY5fhQsvzhvj6eS4DqqmghXTXvv6bO6EHwrsE8@jv2ptF1Y09f0QZ@Dr3q7LF3Xj8GC5399tGxceKCuGhvFwfHn6zvCwSm5endvu5040HgcJwZcc40yyDIkQSIGLBWZ5KnSZqVkpleC/zNBUgGTiiGtwRitjUE8SxUopWYNQCmwF5BItQ4xCwQiE07MfAFCcC7EXATlXAb@Ag "PowerShell – Try It Online") - .NET
It occurred to me after writing both of the below regexes that an entirely different approach would also work.
```
# Search for a "first half", which is repeated exactly following itself
# (except that there can be a decimal point anywhere in either half, which
# is not repeated), with the end of the string following that in turn.
((.).*)      # \1 = part 1 of first half;
             # \2 = first digit of this half (the return value)
             # A decimal point may be here in the other half.
,?           # Skip a decimal point, if there is one in this half. If there isn't
             # one here in this half, there must be one here in the other half.
(.*)         # \3 = part 2 of first half
# Match the other half, which is an exact repetition of the first half
# except that a decimal point can occur anywhere in either half and is
# not repeated.
\1           # Match part 1
,?           # Skip a decimal point, if there is one here.
\3           # Match part 2
$            # Assert that we've reached the end of the string.
```
It even *almost* works in [GNU ERE](https://www.regular-expressions.info/gnu.html#ere):  
[Attempt This Online!](https://ato.pxeger.com/run?1=lVTLTttAFN105a-4NVWxYRI8NrGdpAHxiMoGkCAVVBBZqTNJRji25UcDaaPuum-33XTTZXf9Gbrsl_SOJ-QB6aKj2DP3fe6ZG3_76cdBnorH6_v-_YsrtXQRkNJYJcUhzTr-TSnlY9agtuM4JrXV9v2nNR76Qd5l8CrNujwqD3aUuYpHaZawznBRl7A-u112Qyce9lfpdhR_0EnAi6_a0IAzdX80unln5W_v7i5bA3s00H7kWa_k_tK0sl7e0Mmuhu9rSnavrRfS9PtZoj-OUglsxA0v3qR1Za3LejxkcH50euEd77UOjoACbG0BFg77DLIIDPFitzFL-JCFGYx4NoAwyiAdRCMECdmAwbCT-YP1FN53gpwpHN2GHR5quvJBAVxF114m94NoGPOAdeuFKb7CXgMWarFeou2GIbW8Bxo6--iqvVyKIhATOGu-9pqXrebJYfMQPoK2AH8XAdcKh5PT8zf7uq4XCSUOsXpxnqWaehDlQbfow5eZBbg8QLqx14SlKY_CMlKF98qSRK_P4hOW5UkIVGomckOvWk1eGvAQK9Qf-i6Y8TLJ0BU1jLY09aIENEHUGHuW8X2WBXgZWiH4PCQylV5HH6ovtCDYGeuANjEf2vp1uL4AUFjnhGBcb5TwjGlFsrLvIUxNn-Yui4kWEi06jYpqU4bgz-evoM71k1kF2YvRLidDL41wNI36ShsTtsU6yyCLe2X-kwt-BFSERj2tSKxvTaUNKRJZT07EeWvvTMyEDo3GdAIeKJjVnU_A0syoJ6dQnFUcHhRaUmoe1hYZmGWZAAtS9pTp5TIraIfNKUHmlDyyJCNhpScO9N8AVvWlHot41q0VupXol27h-WIH_zkqyjzd9G-BkzCRn57v918MQl3qKjaxbcUilmIQo2LaFq04bnXbsWx326QrNIrlEMNyDMV1SbXqutWqQu2KQ_CzK3ZcSoUYcilmxXXxJzaCj1LFkKqIIKZJqWmKA-6UWvhIZH8B "C++ (GCC) – Attempt This Online") - but fails on the `5.0000000` case, because this engine *really* [doesn't like to backtrack much](https://sourceware.org/bugzilla/show_bug.cgi?id=11053). The strangest thing is that if `REG_NOSUB` is enabled, it claims to match everything... is it lying? It's Schrödinger's match. (You can experiment with that by changing `SHOW_MATCH` to `0` in the test harness.)
This 20 byte regex obsoletes the other two below, as it runs at the same speed or faster... but I'm not sure if I want to delete them, since they're interesting in their own right. And they would still be the only working solutions if the entire string could be littered with any number of decimal points.
# Regex (.NET), 39 bytes
```
(?=((.),?)*$)(?<=(?(2)$)(?<-2>(\2),?)*)
```
Returns its output as capture group `\3`.
[Try it online!](https://tio.run/##bU7LasMwELzrK4wRRCqy0SPWI67rQM/9gjSHkCqxwLGN7OCSkGs/oJ/YH3Hl5NBLlx1md4YdtmtH6/vK1vUEfbHx9mg/t6tVY0e0XkyoLBBKMSnxE8SofC5QiTi@jwl/Qe/8buFpsSbxa3vqXG0/YpzDS0HzQ@vtbl8hWEeuiaBruvOAr@6A4KmAPn3bDfvK9sHGD/WCr6N3g02qth9uIYLlf3uUNG34qXaNjeKQ@PP1HcGQlB59e@76jdji@HabKGGaaSCJlEAQASihGZeCZUqbpRJSLzn7RwFCESoUBVoTY7Q2BjCZKaKUmjkUyAh9FOCZ1qFnIgHAhBMzXxDOGeN8HgIzJgJ@AQ "PowerShell – Try It Online")
This works (using .NET's Balancing Groups feature) by pushing a portion of the end of the string onto the group `\2` capture stack, one digit at a time, and then scanning in reverse from the position it started from, popping off one digit at a time from the stack to check that they match. The last one popped off is then the return value, if it matches.
```
              # No anchor - This regex will try starting its match at each
              # character of the string until succeeding.
(?=           # Positive atomic lookahead - Match the following, but then
              # return to this position.
    (
        (.)   # Push a digit onto the group \2 capture stack.
        ,?    # Skip a decimal point if there is one here.
    )*        # Iterate the above as many times as possible, minimum zero
    $         # Assert we've reached the end of the string.
)
(?<=          # Lookbehind - evaluated right-to-left
              # (read this from the bottom up)
    (?(2)$)   # Assert that if the group \2 stack is not empty, we're at the
              # end of the string (which is impossible). Basically, assert
              # that the group \2 stack is empty.
    (?<-2>    # Pop a capture from the group \2 stack and match:
        (\2)  # \3 = digit that matches with \2
        ,?    # Skip a decimal point if there is one here.
    )*
)
```
[Try it on regex101](https://regex101.com/r/SDieAA/8) - putting this link down below here because regex101's .NET support is a bit buggy. With this example, it sees the capture groups in the wrong order, and thinks the return value is in group 1.
# Regex (PCRE2), 48 bytes
```
(?*(.).*(.*+))((.),?(?=.*(?=\2$)(\5?+,?\4)))+\5$
```
Returns its output as capture group `\1`.
[Try it on regex101](https://regex101.com/r/SDieAA/7)  
[Attempt This Online!](https://ato.pxeger.com/run?1=bVBBb9MwGBVX_woTRaq_1m3jpEmchciatjAmQTuFclomqxRnjZS2UZKdEFfu48plEuJHjSO_hC8pJ4Tlz-_5-b1Ptr__qHf1068Xn14pJNRuaEKtuUVntG7MvW5MXW22ho3ms7HSerepOr097uuyMk3OcojzbN6OOB1hFSjqe9MbDp05dC3T-vX121Rr4FQAtsTGMSmODbPLxIntKinQ3rL368vrJcTwmZYFs6vbtmsqc0AGU3GXJFZ-sADN7cNHPEGZO3wqIB7cJZjt7thbYopdRUwo7RVq2RX9_fUbRX14yX7TbXfMbjjm7T2mB9dwVG3aTpumwYvBy-QmS6_0cqXTLFtlykp73Tpj9l6xsm1Nh-xW3IEa4MxarujF-c36Q5ZaMOzena8v3lgQf_nnuxjEPx-6YiqfHabGbAYzXMYTAIacK6YSFFSSuzaw3FcTrvIFAExy3z7lnv7C86PDhRSSBDwIiMc94nDHdwNP-KGMFqEXyIUr_qMQL-SOFzpESh5FUkYREYEf8jAMe8RBfO6cBnF9KXH2wLFIhJGoT3DXFcJ1e4IohId1utkf "PHP – Attempt This Online")
```
                   # No anchor - This regex will try starting its match at each
                   # character of the string until succeeding.
(?*                # Non-atomic lookahead - Match the following, but then return
                   # to this position; if a non-match is subsequently found,
                   # backtrack to here and try other possible matches.
    (.)            # Capture the first digit in \1; this will be our return value.
    .*(.*+)        # Search for a \2 that is the last instance of the entire
                   # repeating pattern, using non-atomic lookahead.
)
(                  # Loop the following:
    (.)            # \4 = a digit
    ,?             # Skip a decimal point if there is one here.
    (?=            # Positive atomic lookahead - Match the following, but then
                   # return to this position.
        .*(?=\2$)  # Skip to where \2 begins.
        (          # \5 = the following:
            \5?+   # The previous value of \5, or nothing if this is the first
                   # iteration and \5 is unset.
            ,?     # Skip a decimal point if there is one here.
            \4     # Match a copy of the digit captured in \4.
        )
    )
)+                 # Iterate as many times as possible (minimum one) to match the
                   # following assertion:
\5$                # Assert that the \5 we captured is identical to \2 and is
                   # located at the end of the string.
```
This uses a PCRE2 feature, non-atomic lookahead `(?*`...`)`. I'm pretty sure it's also possible to solve this without non-atomic lookahead, but I'll look into that later.
Note that the only reason this regex is so complicated is because of the presence of the decimal point. If not for that, the solution would be [`(?=(.+)\1$|.$).`](https://regex101.com/r/SDieAA/2) (which is what I came up with before realizing the decimal point was in the way, when I still wanted to return the output as the match instead of a capture group), or what is used in [ovs's Retina solution](https://codegolf.stackexchange.com/a/250067/17216), [`((.).*)\1$`](https://regex101.com/r/SDieAA/6).
But this is a pure regex solution, and can't do any substitutions before doing its matching work.
## \$\large\textit{Full programs}\$
# [Ruby](https://www.ruby-lang.org/) `-n`, 27 bytes
```
~/((.).*),?(.*)\1,?\3$/;p$2
```
[Try it online!](https://tio.run/##KypNqvz/v05fQ0NPU09LU8deA0jGGOrYxxir6FsXqBj9/29oZmquY25uDqKB4F9@QUlmfl7xf908AA "Ruby – Try It Online")
# Perl `-p`, 28 bytes
```
/((.).*),?(.*)\1,?\3$/;$_=$2
```
[Try it online!](https://tio.run/##bYtBCsIwEEX3c4pQgrQyaiZpkgmheJGCCxEUahvUlQfwAB7RgxhT3fqZP2/mw0@Hy2Dz/jidUy2HTu6aKOR9sUiX03ir@rGK8t5RFN9fyAEr8Xo8RRXzpq7XzXrZ4LYuuyfc9kZuotx1UueskJgYHDoHBg0oVFY7Q9ZzaL1x3Gr6k4DxqIxXwIwhMIcA5KxH7/3MIrCofgJtmcvMwGIIpRLmBmpNpPV8FBKZ4veUbqdpvOZV@gA "Perl 5 – Try It Online")
### \$\large\textit{Anonymous functions}\$
# [Ruby](https://www.ruby-lang.org/), 33 bytes
```
->s{s=~/((.).*),?(.*)\1,?\3$/;$2}
```
[Try it online!](https://tio.run/##bUxbasMwEPzfU6jBEKesHa0U64FQcxA7FELtViBMiB1KKe1nD9Aj9iKuRNK/Ljs7s4/Z8@X4tgx@qR6m98l/bsuy3tT3G9yXqXaE@04WW1eIjyV47tjrS4g9i/65nydgLAws3OX56TJPjvXjk2PBk8uL2FZ08H7VjSuXHLHldV2Jw@2qePRjiOnF6RzGmUV3E2v28/XN1n/t0MarY@FIhgwoVAokSuDIG6EkNdrYnZbK7AT9MwGpkUvNwRi01hhrgVSjUWudOQU0yK8BojEmZSZMAJssNjtQCCIhskhMJBN@AQ "Ruby – Try It Online")
# JavaScript (ES6), 37 bytes
```
s=>s.match(/((.).*),?(.*)\1,?\3$/)[2]
```
[Try it online!](https://tio.run/##bUxLTsMwFNz7FF6gxqYP158mtonSrjkDZRGlrggKTrFdWFTdcgCOyEWCAxsWHb15M3qaeS/texu70B/TnR/3bjo0U2w2kb22qXsmK0IYZbcUtiTvnYDtTt2s6KN8murY8Dq4t1MfHCmCa/dD711BWZd9cg8@uXBoO0fOvT@e0v0xjJ2LkcW07/2FstGT4rcBQ7M5I4wjXizwv9R4Suwj9Cl/3/mC1jg2os65q5FhWeDvzy9cLA9koLS@0ImDMMKgCqoKKVCIAy9lpUSpjV1rVZm1FFcuSGngSnNkDFhrjLVIVKUGrfWsGagE/gckS2PyzAKZyOaKnRsgpRBSziarECrzBw "JavaScript (Node.js) – Try It Online")
# [Julia](https://julialang.org) v0.4+, 38 bytes
```
s->match(r"((.).*),?(.*)\1,?\3$",s)[2]
```
[Try it online!](https://tio.run/##bUtbTsNADPz3KVYRH7vIrda7zT4UhR6E8hFotgRtU5SkEsoBOABH5CLBAcQXlj0zHnterrlr6G1J9TJu7s7N9PQsh0LKrdreKtxLxgPh/mBvChzVvXlY5jo1eWwrkS6DyKLrxdA2x9z17SgVCHHKl8cmi7nqEsPr0PVT7qWq2v5YibmehmvLX9@@zKr6VYX4fP8Qxd@e@KaAM4tGChTAoXNg0YJGXRpnqfQh7rx1YWfoHwesR229hhAwxhBiBHKlR@/9ylxQov4pMGUI3CshD0SOxDWBxhAZswpmIsvzBQ "Julia 1.0 – Try It Online")
# [R](https://www.r-project.org) v4.1.0+, 48 bytes
```
\(s)gsub('.*?((.).*),?(.*)\\1,?\\3$','\\2',s,,1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bU49a8MwEN31K0QoSApXo4_YkjDGf6B7Fy1pYwWBcYJkLwldu7drl7TQH5W1v6QyTrce9-7dHby79_EZL1---Z5Gf2-u3NHE9ml6oqRYt5QWrFgzaGmuzglonVN3BIhzkkACEOymO6eG1_jU-NB3dJXGXRhWrMb-EGmPw4DTdDzGLqXHbRzCsE80dtvdQxi6RE-MsTPCOPj8-nk7UuIGwurUiBrHxtM-35nXf0zwz-s7JrcpspfFwuX6xkEYYVAFVYUUKMSBl7JSotTGbrSqzEaKfzZIaeBKc2QMWGuMtUhUpQat9cw5UAl8CSRLY3LOBBnIZomdFSClEFLOTWYhVMbi7Bc)
# Java 8, 49 bytes
```
s->s.replaceAll(".*?((.).*),?(.*)\\1,?\\3$","$2")
```
[Try it online!](https://tio.run/##bVHLbtswELzzKzZqkJAyw@gR6wFFNnLpqe3FxzgHVpFsujQtiHTSoPW1H9BP7I@4K8tGgTqEqKV2dmZ2qZV8kTer5297tW43nYMVfoutU1o0W1M5tTHCL@AM9AtSaWktfJbKwA8C0G6/alWBddJheNmoZ1gjRmeuU2bx@ASyW1h2KAX4eNS@H1A@hAk0UO7tzcSKrm61rOoHrakn/Cmlggmf8SnF93we8ul8Hl963LuMPLYvUHNWSWPqDpRptw5KMPXrKUdnb9bVa6EMw0mMA1UGBbwula6BHurFUtov9XdHGTYIqqHqogzYkbZBvMX2nDa0FyjD4jDD0DNoNBtEDCp8UqY@VDVAtdC1WbglZZMArq5Ai2opuwdHA3ZRXn@4ZgcZFPrPh2oUOEt68OfXb/BYcWTd@qebtdhBI2Tb6reeesSbTddPhz@tn3Z1b4/d4Hk0Olm/Y24fV08j7yca@bfn6D8fNNrtdvuAh1mYkYQnCYl5TAIejKMkDsdplt@lcZLdReE7GRKnPIjTgGQZz/Msy3MSJuOUp2naR1xkzINhkWicZfj0geMmOVLynsGjKAyjqD9gDMMY918 "Java (JDK) – Try It Online")
Java's `split` method just doesn't work the right way to be useful for this.
# [PHP](https://php.net/), 54 bytes
```
fn($s)=>preg_split('/(?=(.+),?(.*)\1,?\2$)/',$s)[1][0]
```
[Try it online!](https://tio.run/##bYyxTsMwEIZ3P0UUWaoN19ZnN7GtYLKwsLDAlkRIoKSJFLVRUibEygPwiLxIOMPKyXe/9d93/9RP60059VPCu7B2J8EXGW6nuT0@L9M4XMRmL8ogdtcSSrG7kjVCWWsu9xsgssKmUs1adOdZ8CGogo@hO7aXRTw@3d0/yEK@J0Mn@Fgtl3lsKX2UW2xCSOtTKgle3l5oQzYo2KIsfulBtq/9OSJFQqlIcw48xhAQV0nKx@T784v8tPhYFaBDx3LIc2bAMAUq07nBzDp/sCZ3B43/OMxYUMYq5hx475z3DPPMgrU2KhXLQP0V05lz9KIANfN04uMFaI2odfyQIhrqHw "PHP – Try It Online")
# [Python](https://docs.python.org/), 57 bytes
```
lambda s:re.split(r'(.+),?(.*)\1,?\2$',s)[1][0];import re
```
[Try it online!](https://tio.run/##bU1bTsMwEPz3KSyBlIQukdduYjuV1VPwlfSjkAQsuU7kGKFegANwRC4SHB5/rHY0u6Od2fkaXybP15unqbf@2TwoYi/zFCJdrsthNN3qzpfH/kyXJgzlMjsb85Dl5a6AY17eFR3CseO3GSxFi6eWnQ6/9jCs1jAyToE6av0WVy4x/WgItSN1g89dQc@@p669x5MxWeezhjrjWtYk4fvKNnQO1se0GDz8ZUyvsXwLNg6522X08/2DZrsxpRUrA1SoSA11TQQIwoBVvBZYSaX3UtRqz/EfhQgJTEhGlAKtldKaYF1JkFJunIpUwH6K8Eqp1BtBAtHJojcHcI7I@TYkRhQJXw "Python 2 – Try It Online")
# [Python](https://docs.python.org/), 61 bytes
```
lambda s:__import__('re').split(r'(.+),?(.*)\1,?\2$',s)[1][0]
```
[Try it online!](https://tio.run/##bU5basMwEPzXKRZakNRsjR6xJTmYnKJfTjBpk7QCRTa2SskFeoAesRdx5Yb@ddhhdofZZYdreuujmu9e@qOPr82TJf4y9GOC6TptwDeCnPsRAvi4OMWUcqwm4M8QTpEFDod4hNA@yn3T0F2kNYQmtKLOxm/K1zCMPqY8NHLzd6N/T8XH6NOJhRWF788voCs2h8Pl@XiAqe662xNdx@h4oryYhuATGykrVhy3rHjgO4nbnbqnOPFW7luxn3n@hs8CpZWWVFhVRKMmAkWpKi1LY93a6MqulfzHIdqg0EYQa9E5a50jsioNGmMWzSAlihuIKq3NtQhmEpdX3LKBSkmp1NJklVJn/gA "Python 2 – Try It Online")
(If it must be a pure lambda.)
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 19 bytes
Uses `,` as a decimal separator.
```
,
.*?((.).*)\1$
$2
```
[Try it online!](https://tio.run/##bYs7DgIxDET7OccW2ZW1sp2NPxUll6CAgoICCsT9QyJaRjN60kjvff88Xjfpz3K@dgL27VTKvu7bepEFi/bOJCEBIzNUqmDiplaleeTh1eJQ@fOgOnF1RgRlRmRCrDm5@@QIGvEv0BYxOkFjyKHkNEhVRPUL "Retina – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ḟṂŒHÐƤEƇFḢ
```
A monadic Link that accepts a string of digit characters containing a decimal point, `.`, and yields a digit character.
**[Try it online!](https://tio.run/##y0rNyan8///hjvkPdzYdneRxeMKxJa7H2t0e7lj0//9/JWMgMDQyNDI1NjLUMwSRhkoA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##bY49CgJBDIX7nEPYLkwmO5PkAP5cxEb2ArbbbCteQBBLS4sV7Zbde4wXGWew9fEeX3jwIId91x1zTuMlPfv5vJtOy229DJs0XnN6Peb3NHz6@2qbc9M0DklJIWKMwMjg0AUfmYKotcJRW09/GmBBx@JAFc1UzYBiEBSRyiII6H4CH1SLK7AErEysLtB7Iu/rUUjEJeWnLw "Jelly – Try It Online").
### How?
```
ḟṂŒHÐƤEƇFḢ - Link: list of characters, N
 Ṃ         - minimum of N (guaranteed to be the '.')
ḟ          - filter ('.') from N
    ÐƤ     - for each suffix of that:
  ŒH       -   split into two halves
       Ƈ   - filter keep those which are:
      E    -   all equal (i.e first half = second half)
        F  - flatten
         Ḣ - head
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ ~~13~~ ~~12~~ 9 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
RþηD2×Ãθθ
```
-1 byte porting [*@JonathanAllan*'s Jelly answer](https://codegolf.stackexchange.com/a/250082/52210)  
-3 bytes thanks to *@CommandMaster* with a very smart usage of `Ã` as golf on my 13-byter(s)
[Try it online](https://tio.run/##yy9OTMpM/f8/6PC@c9tdjA5PP9x8bse5Hf//W@oZGBoaADEA) or [verify all test cases](https://tio.run/##bYsxCsJAEEX7OUVILcPMbHZnpkrjCbyBgoWVhSAE7AQPYONRksom/R7Ci6y72Pr5jw8P/vmyP5yO5Xadxr77PJ5dP05lt77zvJX1td7zkpeyKYRsbJAwJQgYgJCipMBRzQcNyQbhPwaCIgUlMEN3M3fgFBVVtW0NRKRfQKJZbRusgNeLtweKMItUQcxU@QI).
**Explanation:**
```
R          # Reverse the (implicit) input
 þ         # Remove the dot by only keeping the digits
  η        # Pop and push a list of its prefixes
   D       # Duplicate this list of prefixes
    2×     # Double each string in the top prefixes-list
      Ã    # Only keep those doubled-prefixes from the prefixes-list
       θ   # Pop and push the last/longest
        θ  # Pop and push its last digit
           # (which is output implicitly as result)
```
[Answer]
# [Python](https://www.python.org), ~~68~~ ~~62~~ 57 bytes
```
lambda x:re.split(r"(.+),?(.*)\1,?\2$",x)[1][0]
import re
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bVBLTsMwEBVbn2JksYhLGPnT-FOr6kGaLgIkIlKbRK4rlbOwqYTgTnAabAKsOmPPk97Ms0fv9WN6ic_jcHnr1vX7KXb39tPtm8PDUwPnVWjxOO37WARa4B0rNwUuWC3KTS1vaXlmW7Hb8h3pD9MYIoR2fuDrhsX2GNeUUo7CCutBEI1ae9BEofKgCEdeSa1EZaxbGqXtUoorjIeKKINcGZ5V1qJz1jrnwRKhK4PGmIwp8icV8jk8cCIra9PJgOl6kMQluctqRwRKKYSUiU57EpI3hjVsF4dmKv4NgPOvAdQDZSXkqT-mHihjOyDdGKAfpnI8xYQ_IysCMIV-iEVudLliaKd989gWFGmZkrEsYLNjl8uM3w)
Takes in a string with `,` as the decimal separator.
---
-6 bytes from @loopy walt by using `$` instead of reversal.  
-5 bytes from @loopy walt / @DeadCode using the matching regex to ignore the `,` instead of adding a `re.sub`
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
←ḟoE½ṫf±
```
[Try it online!](https://tio.run/##bYu9DcJADIV3uRpZZzvnH1EzBaJFSCiiQAwABTUbMAAVXShoskmyyOFTWp5sv09PfofL@Vj7dT/frnW@P6bhedqM3@nz2o/vWus2ZUBDS6skIBLGwHEz5ELCWNS8UxbrCP8k7V8hszYyA3cz92CUoqCqzUORFMiLgqmYxTSD2Eg8qr40gQiRaMEgRI5Nux8 "Husk – Try It Online")
```
      f   # filter to keep only
       ±  #  characters that are digits,
 ḟ        # now get the first 
     ṫ    #  of all the tails (possible 'bb's)
  oE½     #  which is two copies of the same thing,
←         # and return the first element.    
```
[Answer]
# [Raku](http://raku.org/), 31 bytes
```
{+(S/\.//~~/((.).*?)$0$/)[0;0]}
```
[Try it online!](https://tio.run/##bYvBCsIwEER/ZShFWoXNbmKSDdr6ER5VxIM9KYqeirS/XlO8OszwhoF5Xl@3MN17LDo002dV7c2RjBlHU1VU03JXl1ya@sAbPg3T@9KjKM9oWnw6lOehQPd4YcskKopAIcCRAxN7G5z4qGkdXdC1lT8LXCR2kaFKKammBAk@UoxxZhY88U@wXjV7BuUg5UuaH2StiLVzyRRxOe30BQ "Perl 6 – Try It Online")
`S/\.//` returns a copy of the input string with the decimal point removed. That string is matched with `~~` against the pattern `((.) .*?) $0 $`, which looks for the repeating portion at the end of the string. `[0; 0]` looks up the first submatch group of the first match group (ie, the digit matched by the `(.)`) and `+` converts that match object to an integer.
[Answer]
# Excel, ~~118~~ 104 bytes
```
=LET(a,MID(SUBSTITUTE(A1,".",),ROW(1:32767),2^15),b,LEFT(a,LEN(a)/2),LEFT(INDEX(b,MATCH(TRUE,a=b&b,0))))
```
Input is in cell A1 of the active sheet. Output is wherever the formula is. Breaking down the `LET()` function into the `variable,value,...,output` format, we get this for the first two terms:
* `a,MID(SUBSTITUTE(A1,".",),ROW(1:32767),2^15)` removes any decimal point and then creates an array 32767 rows tall where each row removes another character from the beginning of the string. Most of this array will be empty, of course, but this is to accommodate the [max number of characters allowed per cell](https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3).
* `b,LEFT(a,LEN(a)/2)` creates an equally tall array of the first half of the first array.
Now it gets into the more complicated final term:
```
LEFT(INDEX(b,MATCH(TRUE,a=b&b,0))))
```
* `MATCH(TRUE,a=b&b,0)` finds the first row where `a` is exactly `b` twice.
* `INDEX(b,MATCH(~))` pull the entire value of `b` from the array at that point.
* `LEFT(INDEX(~))` outputs the first character of that result.
---
Screenshot with details for one of the test cases:
[![Details](https://i.stack.imgur.com/sxYkg.png)](https://i.stack.imgur.com/sxYkg.png)
---
Screenshot with all the test cases:
[![Testcases](https://i.stack.imgur.com/o8V1S.png)](https://i.stack.imgur.com/o8V1S.png)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), ~~13~~ 10 bytes
```
~±ÞKvI~≈fh
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwifsKxw55Ldkl+4omIZmgiLCIiLCJcIjAuMTgxOFwiXG5cIjYuNjZcIlxuXCIzLjNcIlxuXCIwLjA1MjYzMTU3ODk0NzM2ODQyMTA1MjYzMTU3ODk0NzM2ODQyMTBcIlxuXCIzNy4wMzcwXCJcblwiODguOTk4ODk5XCJcblwiMTY1Ny43NzcxNjU3Nzc3XCJcblwiNS4wMDAwMDAwXCJcblwiMjU4ODU4ODI1ODguNTg4XCJcblwiOS45OTk5OVwiXG5cIjEuMjIxMTIyXCJcblwiMS4yMTEyMTEzMjExXCIiXQ==)
```
~±ÞKvI~≈fh
~±         # Filter for numeric, to remove the ".". Converts to list of chars
  ÞK       # Suffixes
    vI     # Split each into a list of two halves
      ~≈   # Filter for all equal
        f  # Flatten
         h # First item
```
Original 13 bytes was porting UnrelatedString's Jelly answer, but porting Jonathan Allan's answer saved 3 bytes, so upvote those two!
Alternative:
# [Vyxal](https://github.com/Vyxal/Vyxal), 10 bytes
```
goÞK½~≈hhh
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwiZ2/DnkvCvX7iiYhoaGgiLCIiLCJcIjAuMTgxOFwiXG5cIjYuNjZcIlxuXCIzLjNcIlxuXCIwLjA1MjYzMTU3ODk0NzM2ODQyMTA1MjYzMTU3ODk0NzM2ODQyMTBcIlxuXCIzNy4wMzcwXCJcblwiODguOTk4ODk5XCJcblwiMTY1Ny43NzcxNjU3Nzc3XCJcblwiNS4wMDAwMDAwXCJcblwiMjU4ODU4ODI1ODguNTg4XCJcblwiOS45OTk5OVwiXG5cIjEuMjIxMTIyXCJcblwiMS4yMTEyMTEzMjExXCIiXQ==)
```
goÞK½~≈hhh
g          # Minimum (".")
 o         # Remove it
  ÞK       # Suffixes
    ½      # Split each into a list of two halves
     ~≈    # Filter for all equal
       h   # First list
        h  # First string
         h # First character
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 7 bytes
```
ịˢa₁~jh
```
[Try it online!](https://tio.run/##bYsxCgJBDEWvskytYZLZmWQaPYhYrBYuIgg2i4iCWwhi4xk8gY2NHsFT7F5kzLCtnyT/8clf7Kplvd9sV5QOjSnGk8I00/7y7Nu2e1@P3eueus/t@6j69nxa1ynNjAUUFDMyAUJQc@D0WrCegkPPEkt2QUrCP0n@Z7COM4lAjCIxKmPwDMycXaWJBztImbyITjbQ1SRqNQ5NIEIkGlAJ0ema@Q8 "Brachylog – Try It Online")
```
ịˢ         Filter the input to only digits.
  a₁       For some suffix (tried longest first),
      h    output the first element of
    ~j     a list which repeated twice is the suffix.
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 26 bytes
```
**((~/2 0N#)')#(1_)\(46=)_
```
[Try it online!](https://ngn.codeberg.page/k#eJxtTLkNwzAM7D2FIReRXDAiKfEJkBUyQQB3HiOzRw/c+UDiHoJ3vvY9xt+T1vzZ0iNtEY/0jUXe6ViWcw0Z0NBClwIiQzBwmLdcSRirmhdlsUJ4k8wfhcw6tRm4m7kPh1IVVLVzw8gq5InhqJq16QRtR+atwq8GIEIkukzTiNw2/AElDis5)
## Explanation
* `(46=)_` remove decimal
* `(1_)\` generate suffixes
* `((...)')#` filter each suffix...
	+ `2 0N#` halve suffix
	+ `~/` check if halves are equal
* `**` first of first
[Answer]
# [Python](https://www.python.org), 74 bytes
```
f=lambda s,i=0:s[n:=i-len(s)]*(s[n:]==s[2*n:n])or f(s.replace(".",""),i+1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bU45bsMwEOz5CkIV6cgLHhYPEaoD5AuGCiWRYAIyRYhKkbekUeP8yb8JCbvMYBeDHezM7s9v_N4uS9j329c2Hc39berm4fr-OeBU-4616Rzazh_nMZBE-wMpc9916SwOoQ09XVY8kQTrGOfhYyQVVHVV0dq_cPpMfJ3yzuzDiH3AS8xBjLYI-3rprkMkaVsht4912YEUZ7-RylWUIhxXHzYyEU_r5Rm3328MuOHGYY4UKOWwQhKkwxIxYI1Qkjfa2JOWypwE_0dxuEFSA5OaFZcxYK0x1jpsEFeNBq114YxypAH2gMMMicaYXIUgt8MC2Wy3xW0RByE4FyLLj2__AA)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 bytes
```
ḟ”.ŒHẆf/ƊÐƤFḢ
```
[Try it online!](https://tio.run/##bY4xCgJBDEX7XGS7OMnsTDIXEK/gAbSQvYCdWChYib0IYmlpsWi5uPcYLzJmsPXzPy98@JDVouvWpeT@8tmc8X2a5eduORkPw3G8TXN/Lfn1GPaf7X1eStM0DklJIWKM4NGDQxc4egqiqRUftWX604AXdF4cqGJKqikBxSAoIpUmCOh@Ag6q5gq0QLJJqgtkJmKuh5HIW@ynLw "Jelly – Try It Online")
```
ḟ”.              Remove the radix point.
        ƊÐƤ      For each suffix:
   ŒH            Split it in half,
       /         and reduce
     Ẇ           the sublists of the pair of halves
      f          by filter left by membership in right.
           F     Flatten the results
            Ḣ    and yield the first element.
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 46 bytes
```
s=>/^.*?(.*)\1$/.exec(s.replace('.',''))[1][0]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bVFLbsIwEFW3PoUXSLZpGGKHxE5RwqqnACqi4LRIIYnykZAQJ-kGVe2RumhPUxsX1EVHHs28mfeeLfn1vaq3-vxWJB9DX0zUF3RJOn2C8YLCmK34aAr6oHPaQaubMss1JUA8Qhhb8vXSXzvV993nHKEN8oErrvAkxRxFEEW2i1AAgW0Cs_ZDEQU8lCqeySBSM8H_mVhyiAIJfiB9p1QK4lipOLZQIR6FEqSUtppwF4bgu7DQRyJUyhxbwKQdChQbm9i5xIiDEJwL4VYGGcB5YNIZbqBvd3vKoGvKXU_JqiIMirp9zPIX2uuux0mKjwjjvK4MWHp4VzVD72F9aHTer3GCLQv2WW8EUwr3zBrbOmXzm67V3VAaL1zQi_7Pqsm6ziyujOTX-UqoSw1l_UwvtAUmq0FIPyT4wbWznNyeRCapAc7Iw1eBpW6oM9VbPDq69sQ25hEnNne_ez67-gM)
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 65 bytes
```
f=lambda s:(s:=s.replace('.',''))[:s==s[:len(s)//2]*2]or f(s[1:])
```
[Try it online!](https://tio.run/##bY0/b8IwEMV3f4rb4lTIxDaJ/ykjXbt0QwwBjIgaEss2avn06ZmuPfnpnZ7vdxee@bbMUoe4rtd@Gu6nywDJ0mT7xKIP03D2tGLVpqrq@mBT36eDnfxMU73diuObOC4RrjQduD3W6/dtnDx8xoe3BCDHZzGAcQ4bWB4ZergPgaYcGWrEEH8emdYshWnMtHJ45EWEOM6ZIrLB5Tj0iv3P2YcM@4/3fYxLtHCKfvhaG8Y11w446VjXOeiIZNKBJA1rWtFJ3iptdkp2eif4P4mDlkjFGqmaQmnNjNHaGAea8K5VTClVHKscaVnzVw4aIlqt8RVjKAeCGMRNoQ3hTAjOhSgx9thyLlG45hc "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [lin](https://github.com/molarmanful/lin), 35 bytes
```
"\, !="`#"1`d"`it"`bi \`= `/"`?' `^
```
[Try it here!](https://replit.com/@molarmanful/try-lin) Takes string with `,` comma.
I recently added string literals to lin, still not sure if I regret doing so...
For testing purposes:
```
"1,2112113211" ; outln
"\, !="`#"1`d"`it"`bi \`= `/"`?' `^
```
## Explanation
More readable version:
```
( \, != ) `# ( 1`d ) `it ( `bi \`= `/ ) `?' `^
```
* `( \, != ) `#` filter out comma
* `( 1`d ) `it` generate suffixes
* `(...) `?'` find first suffix that satisfies the following...
	+ ``bi` split suffix in half
	+ `\`= `/` check if both halves are equal
* ``^` first element
[Answer]
# Excel VBA, 107 bytes
```
Sub o(a)
a=Replace(a,".","")
b=Left(a,Len(a)/2)
If a=b &b Then MsgBox Left(b,1):Exit Sub
o Mid(a,2)
End Sub
```
1. Remove any decimal points from the input.
2. Get the first half (rounded up) of the input.
3. If the whole string is the first half twice, output the first digit of `b` to a message and exit.
4. Otherwise, remove the first letter from the input and recurse.
---
VBA will pad the code with spaces automatically. The above input is valid but here's what it looks like after that auto-formatting:
```
Sub o(a)
a = Replace(a, ".", "")
b = Left(a, Len(a) / 2)
If a = b & b Then MsgBox Left(b, 1): Exit Sub
o Mid(a, 2)
End Sub
```
[Answer]
# [Python 3](https://docs.python.org/3/), 93 bytes
```
def f(s):s=s.replace(".","");return[s[-i:][0]for i in range(len(s))if s[-i:]==s[-2*i:-i]][-1]
```
[Try it online!](https://tio.run/##bY7dasMwDIXv9xQhN3VGIyy7tuWMPEnIRdmczVDc4GQXffpUbWGYMCFx4NPP0Xxbf65Jb9tXmKpJLE239AvkMF/On0HUUB/ruvnIYf3NaViGNnbjIMfpmqtYxVTlc/oO4hISbzZxql4Tfc@q3mPXxnEcWhy3Oce0ikkcJCAhHZojNm9/0IK1jGyBNGgmuiASpFFWo3HkT05bOin8h/CWKe84kNrJ3S0i8J7Ie@ZUcLTGgXPuoRy7Nw3IVzCXBVeGiPMhwMVdVXQ9W/mnky@dQClEpXbDjJkiaq6n@3YH)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 22 bytes
```
§⊟ΦＥθ…⮌⁻θ.κ¬⌕⮌⁻θ.×²ι±¹
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMOxxDMvJbVCIyC/QMMtM6cktUjDN7FAo1BHwbkyOSfVOQMoHpRallpUnKrhm5lXWgySUtJT0tTUUcgGEX75JUCNeSk4VYVk5qYWaxjpKGRqggBQR2p6YkmqhiGQY/3/v5GphQUQgSg9IP6vW5YDAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
    θ                   Input string
   Ｅ                    Map over characters
        θ               Input string
       ⁻ .              With `.`s removed
      ⮌                 Reversed
     …                  Truncated to length
          κ             Current index
  Φ                     Filtered where
            ⌕           Index of
                   ι    Current reversed suffix
                 ×²     Repeated twice
               θ        In current string
              ⁻ .       With `.`s removed
             ⮌          Reversed
           ¬            Is zero
 ⊟                      Take the longest reversed suffix
§                   ±¹  Take its last character
                        Implicitly print
```
[Answer]
# [Haskell](https://www.haskell.org), ~~95~~ 83 bytes
*-12 bytes thanks to [@Unrelated String](https://codegolf.stackexchange.com/users/85334/unrelated-string)*
```
g.filter(>'.')
g x=[x!!d|d<-[0..],uncurry(==)$div(length x-d)2`splitAt`drop d x]!!0
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bZHRaoMwFIbZrU9xlIIKNSSxmgTmYM_QSye01NrKrBUTNwt7gz3CbgpjbK-0PU2T2WEp-8nhcL6TnD8kb5_bpXxcV9VX6gSrpnGy9yJ5-OhUEfDv-QYVZaXWrXfnIte3NtAnaW_b-Ut-G6QYoWza1auubQ9ekviTvHzyqnW9UVvog9ynC9lUpbpXi7zdN5BDn9k2Hkb_3LwqSCC1QMtzMCKccGcKLnH96RnGKI4NikcUotCQcCQY4YjGIYkYFzMWxnxGyT_EnIou5jCEQ4avZnGOhOBcCMP5yEkcMcQYM1nr6poRwoMMxyOnEed6mYR0mC4du0JbicFJXDghSgmh9GqzxpoSEuo4u2eW1Uv9grtlA4VUoKzDXynrXJdWq0vvtw299CFJ4CCt3bKsNW86NVctTEBu98_QDn9yPA75BA)
]