I have a string of words (they are separated by new line)
aa
aaa
aaaa
aaaaa
and I want to add it to an array "words"
[1] = aa
[2] = aaa
[3] = aaaa
[4] = aaaaa
how can I do this in ionic 2? I know in java it would look like this
String s = "This is a sample sentence.";
String[] words = s.split("\\s+");
for (int i = 0; i < words.length; i++) {
words[i] = words[i].replaceAll("[^\\w]", "");
}
but can't figure it out in ionic 2.
In Javascript or Typescript you could do the same with:
const s = "This is a sample sentence."; const words = s.split(" "); // displaying the array for (word of words){ console.log(word); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.