- Read http://www.uccs.edu/~ahitchco/grep/
- Log on to igor (or any other Unix system) and type:
grep -E "^a...d$" /usr/share/dict/words
Describe the output.
- type
cat /usr/share/dict/words
- type
cat /usr/share/dict/words |wc -l
- How many words are there that start with a and end with k?
What are they?
- use grep to find the following:
- All the words that start with 'A' or 'a' and end with a 'c' and have at least one 'b' somewhere in between.
- All the words that start with 'A' or ('a' followed by zero or more 'b's and end with a 'c' and have at least one 'b' somewhere in between.
- Find all the words with all five vowels a,e,i,o,u occurring in order.
- Find all the words that do not have any vowels.
- Find all the filenames on the system that contain your username.
Use the 'locate' comand.
- Find all the words that end with 'and'.
- Find all the words that contain an 'a' and a 'b'.
- Find all the words that contain exactly one 'a' and exactly one 'b'.
- Write a Javascript function which checks whether a list is a palindrome.
- Think about how regular expressions help to solve the `crossword' assignment.
- Read
http://eloquentjavascript.net/chapter10.html
and
look at
http://www.javascriptkit.com/javatutors/re.shtml.
- The following code allows the user to input numbers with or without a decimal point and then adds one to
the value if it is a legal number. Although, accptable, this program allows the user to
enter values with leading zeroes like 00123.5. We want to disallow such input. However,
we do allow a single leading zero if it comes immediately before the decimal point as in
0.54 and also if the number is 0 itself.
Cange the code to correctly achieve this requirement
correctly
achieve this requirement:
<HTML>
<HEAD>
</HEAD>
<BODY>
<p>
Result: <output type=text id="resultInt1" value="" readonly> </output>
</p>
<input onchange="
var k=/^[0-9]+(|\.[0-9]+)$/;
if (k.test(this.value))
document.getElementById('resultInt1').value=parseFloat(this.value)+1;
else {alert(this.value + ' is not a number'); this.value='';}
"
>
</BODY>
</HTML>