Categories
Development Javascript

Javascript regular expression selecting multiple

my problem is selected expressions cant use more than one but i need it

here i prepare a example of what i want

var regexp = /(^| )([a-z]{1})( |$)/gim;

var string = "h ello e x a mple";

var choosen = string.match(regexp);

for(var i = 0; i < choosen.length; i++){
    console.log(choosen[i]);
}

you can see this only chooses "h ", " e ", " a "

but i want to choose "h", "e", "x", "a" without any " "

i know i can do it without regexp but this is really important for me

Leave a Reply

Your email address will not be published. Required fields are marked *