[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed gátur



Sælir,
Er að fara í gegnum kennsluefni á netinu sem kennir m.a. á sed og gengur illa að finna svarið við þessum spurningum. Var að spá hvort einhver hefði áhuga að sýna snilli sína í regexum og sed? Hérna eru þær:

Write a RE to match only words with an even number of letters up to a maximum of 10 letters.

Remove any line that begins or ends with a vowel (a,e,i,o,u).

Look for every line beginning with a '<'

Hverja linu sem er með <div>, case-insensitive

Look for all references to QED. Number each line you find.

Show all lines that are headings (H1, H2, H3, etc.). Again case may be an issue.

Given the following RE's what would they match?
ht\{2\}p:\/\/ = http://
ht\{2\}p:\/\{2\} http:// 
ht\{2\}p:\/\/w\{3\}.*za$ 
ht\{2\}p:\/\{2\}.*\/.\{9\}\/ 

Hverju breyta þessi regex í?
s/\(.*\)@\(.*\)/\2 user \1/g
s/\([-a-zA-Z0-9\.]*\)@\([-a-zA-Z0-9\.]*\)/\2 .. \1/g
s/\([-a-zA-Z0-9\.]*\)@\([-a-zA-Z0-9\.]*\)/<<<\2>>> .. [[[\1]]]/g

 Bestu kveðjur/Best regards, 


Sigurður Jónsson