n°19
Extraire un nombre décimal en Javascript
Javascript
30 nov 2018
function extractFloat(element) {
    element = element.toString();
    var match = element.match(/-?\s*\d+(\.\d+)?/); // captures the first 0 or -0 or -0.0 match

    if(match) {
    return match[0].replace(/\s+/g, ''); // removes whitespaces (if any)
    } else {
    return false;
  }
}

console.log(extractFloat("margin-top: - 66.67 px")); // -66.67
console.log(extractFloat("I ate 10 apples in the last 5 days")); // 10
console.log(extractFloat("2*a")); // 2
console.log(extractFloat(-5.0)); // -5

c. héraud-louisadat

architecte & développeur
67200 Strasbourg
heraud-arobase-laponies-point-fr

*1992, Strasbourg.

Diplômé d'état en 2016 de l'ENSA Paris-Malaquais et de la RWTH Aachen et habilité à maîtrise d'oeuvre en nom propre (HMONP) en 2019, j'ai travaillé pour diverses agences d'architecture à Paris et Berlin puis fait de la recherche en histoire de l'art sur l'architecture Heimatschutz. J'ai fondé l'agence Atkinson-Héraud Architectes en 2023 avec Isabelle Atkinson-Evans. Je développe également des applications pour le Web et la 3D.

Amis, famille et blogroll : Anaïs Héraud-Louisadat, Héraud–Baumann, Till Baumann, Antoine Le Dreff, Station Zéro, BALT.

alsace europe