write a method that finds each occurrence of “abc_” in a string input (where _ is a single character) and prints “bc_” for each such occurrence. for example, find abc(“abcdefg”) should print:
Example 1: javascript create a function that counts the number of syllables a word has. each syllable is separated with a dash -.
function new_count(word) {
word = word.toLowerCase();
if(word.length <= 3) { return 1; }
word = word.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '');
word = word.replace(/^y/, '');
return word.match(/[aeiouy]{1,2}/g).length;
}
console.log(new_count('she'));
console.log(new_count('spain'))
console.log(new_count('softball'))
console.log(new_count('contagion'))
Example 2: write a bash script that accepts a text file as argument and calculates number of occurrences of each words in it and return them as key value pairs
file=/home/stefan/ooxml1.txt
for word in $(sed 's/[^A-Za-z]/ /g' $file | tr " " "\n" | sort -u)
do
echo -n "$word "
grep -c $word $file
done | sort -k2 -n