'how select in text only space have after word
I try to parse text in an array to use it in constructor functions or in variables
make it regular exprecions
[A-Za-z0-9-_+,]+\s?
but does the opposite select words that have space after
let txt = "cart monkey thing";
txt.replace(A-Za-z0-9-_+,]+\s?, "-");
console.log(txt);
//return "- --"
I thought you invest that expression but I do not know how to do it
Solution 1:[1]
You can use regex to select space which comes after word as:
/(?<=\w+)\s+/g
const regex = /(?<=\w+)\s+/g;
let txt = "cart monkey thing";
txt = txt.replace(regex, "-");
console.log(txt);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | decpk |
