JSFiddle - React, Tailwind, and code Playground

by f0t0n

JavaScript

var str,
    re;
str = " my text ";
re = /^\s+|\s+$/g;

console.log(str.replace(re, ''));