Guest_imported
New member
- Jan 1, 1970
- 0
Hi everyone,
I have to write a script that changes sentences like:
Grace met S. Rogers, K. Walters and P. Martin.
I know what U.F.O. means.
He finished as nr. 2.
into:
Grace met S| Rogers, K| Walters and P| Martin.
I know what U|F|O| means.
He finished as nr| 2.
I'm using the following script:
{
if($0~/S\./)
gsub(/S\./, "S|"
if($0~/K\./)
gsub(/K\./, "K|"
if($0~etc)
gsub(etc...)
print $0
}
Does anyone know how I can use regexp in this example in order to facilitate the exercise? It would be much appreciated!
Many thanks in advance!
Kim
I have to write a script that changes sentences like:
Grace met S. Rogers, K. Walters and P. Martin.
I know what U.F.O. means.
He finished as nr. 2.
into:
Grace met S| Rogers, K| Walters and P| Martin.
I know what U|F|O| means.
He finished as nr| 2.
I'm using the following script:
{
if($0~/S\./)
gsub(/S\./, "S|"
if($0~/K\./)
gsub(/K\./, "K|"
if($0~etc)
gsub(etc...)
print $0
}
Does anyone know how I can use regexp in this example in order to facilitate the exercise? It would be much appreciated!
Many thanks in advance!
Kim