Reg. exp. tidying with Ruby

Soldato
Joined
24 Nov 2002
Posts
16,378
Location
38.744281°N 104.846806°W
I'm trying to use regular expressions within Ruby to tidy up some citations.

e.g. Going from:
ALTUVIA, S., LOCKER-GILADI, H., KOBY, S., BEN-NUN, O. AND OPPENHEIM, A.B. RNase III stimulates the translation of the cIII gene of bacteriophage lambda. PROC.NATL.ACAD.SCI.U.S.A. 84 6511-6515 (1987).
to:
ALTUVIA LOCKER-GILADI KOBY BEN-NUN OPPENHEIM RNase III stimulates the translation of the cIII gene of bacteriophage lambda

That is only one example, but they're usually of the same syntax/format.

Any pointers?

For instance, if the 'phrase' contains a . (so is an initial) chuck it out and so on..
 
Last edited:
I don't know Ruby, but I do know a little about regular expressions in sed, and
Code:
s/, / /g;s/\. AND/./;s/ [A-Z]\.//g;s/^\([^.]*\)\. \([^.]*\)\.\ .*/\1 \2/
seems to work

edit: wouldn't work on names with accented letters ;)
 
Last edited:
matja said:
I don't know Ruby, but I do know a little about regular expressions in sed, and
Code:
s/, / /g;s/\. AND/./;s/ [A-Z]\.//g;s/^\([^.]*\)\. \([^.]*\)\.\ .*/\1 \2/
seems to work

edit: wouldn't work on names with accented letters ;)
Holy rap.... cheers!
 
Back
Top Bottom