---
# System prepended metadata

title: T3's regex for CountUp.JS

---

# T3's regex for CountUp.JS

### C#

```
var statNumber = statistic.Content.Value<string>("statisticNumber");
var statHeading = statistic.Content.Value<string>("statisticHeading");
```
```
var pattern = @"^(\+)|\D";
var substitution = @"";
var options = RegexOptions.Multiline;
var regex = new Regex(pattern, options);
var cleanStatNumber = regex.Replace(statNumber, substitution);
```
```
var secondPattern = @"^(\+)|(\d|,.*?)";
var secondRegex = new Regex(secondPattern, options);
var cleanSuffixOrPrefix = secondRegex.Replace(statNumber, substitution);
```
```
var suffixPattern = @"^(\.)|\d|,.*?|.+?(?=[0-9])";
var suffixRegex = new Regex(suffixPattern, options);
var cleanSuffix = suffixRegex.Replace(statNumber, substitution);
```
```
var prefixPattern = @"^(\.)|.*?(?=[0-9])";
var prefixRegex = new Regex(prefixPattern, options);
var cleanPrefix = prefixRegex.Match(statNumber);
```
```
<div class="col-xs-12 col-md-6 col-lg-4 center-xs">
    <div class="m-statistic-card">
        <p class="a-h1 color-text-brand v-no-top-spacing js-countup" data-countup-value="@cleanStatNumber" data-countup-prefix="@cleanPrefix" data-countup-suffix="@cleanSuffix" id="@statistic.Content.Key">@statNumber</p>
        <p class="a-h7">@statHeading</p>

        @* T3 Regex Debugger *@
        @*<p>@cleanStatNumber</p>*@
        @*<div style="display:flex; flex-direction:row;">
            <div style="display:flex; flex-direction:column; margin-right:2rem;">
                <h6>All Characters</h6>
                <p>@cleanSuffixOrPrefix</p>
            </div>
            <div style="display:flex; flex-direction:column; margin-right:2rem;">
                <h6>Prefix</h6>
                <p>@cleanPrefix</p>
            </div>
            <div style="display:flex; flex-direction:column; ">
                <h6>Suffix</h6>
                <p>@cleanSuffix</p>
            </div>
        </div>*@
    </div>
</div>
```

### JavaScript
```
export const initCountUp = countUpElement => {
    const easingFn = function(t, b, c, d) {
        var ts = (t /= d) * t;
        var tc = ts * t;
        return b + c * (tc * ts + -5 * ts * ts + 10 * tc + -10 * ts + 5 * t);
    };

    const prefix = countUpElement.getAttribute("data-countup-prefix");
    const suffix = countUpElement.getAttribute("data-countup-suffix");

    const options = {
        duration: 3,
        prefix: prefix,
        suffix: suffix,
        easingFn
    };
    const countUpId = countUpElement.id;
    const value = countUpElement.getAttribute("data-countup-value");

    let countUpPlugin = new CountUp(countUpId, value, options);
    if (!countUpPlugin.error) {
        countUpPlugin.start();
    } else {
        console.error(countUpPlugin.error);
    }
};
```