i been trying all day to put all letters, into an array from a string
now i only want letters that have no othere letters around them
like... im gonna try to give an example
from "test h lol-k 5b" i would want the result to be an array with ["h","k","b"] (sense they are letters without letters
beside them)
i been trying all day to put all letters, into an array from a string
now i only want letters that have no othere letters around them
like... im gonna try to give an example
from "test h lol-k 5b" i would want the result to be an array with ["h","k","b"] (sense they are letters without letters
beside them)
sry if its hard to understand, thanks
I'm not sure I understand your request.
Why would you not expect the results to be an array of: ['t','t','h','l','k','5','b'] ?
(All of those have a space beside them)
For example:
Code:
<!DOCTYPE HTML>
<html>
<head>
<title> Untitled </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
var str = 'test h lol-k 5b';
var sarr = str.split(' ');
var tarr = [];
str = '';
for (var i=0; i<sarr.length; i++) {
tarr.push(sarr[i].charAt(0));
if (sarr[i].length > 1) { tarr.push(sarr[i].charAt(sarr[i].length-1)); }
}
alert(tarr);
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<title> Untitled </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
var str = 'test h lol-k 5b';
var sarr = str.split(' ');
var tarr = [];
str = '';
for (var i=0; i<sarr.length; i++) {
tarr.push(sarr[i].charAt(0));
if (sarr[i].length > 1) { tarr.push(sarr[i].charAt(sarr[i].length-1)); }
}
alert(tarr);
</script>
</body>
</html>
hm, not really
what i want is all letters, not forming a word (word = more then one letter), so basiclly all letters, not having anotherer letter beside them, its ok if it has signs, or numbers, as long as its not an letter its touch , its really hard to explain, sorry
Bookmarks