Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/String-matching/AWK/string-matching.awk
Normal file
17
Task/String-matching/AWK/string-matching.awk
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/awk -f
|
||||
{ pos=index($2,$1)
|
||||
print $2, (pos==1 ? "begins" : "does not begin" ), "with " $1
|
||||
print $2, (pos ? "contains an" : "does not contain" ), "\"" $1 "\""
|
||||
if (pos) {
|
||||
l=length($1)
|
||||
Pos=pos
|
||||
s=$2
|
||||
while (Pos){
|
||||
print " " $1 " is at index", x+Pos
|
||||
x+=Pos
|
||||
s=substr(s,Pos+l)
|
||||
Pos=index(s,$1)
|
||||
}
|
||||
}
|
||||
print $2, (substr($2,pos)==$1 ? "ends" : "does not end"), "with " $1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue