View Single Post
Old 03-06-2011, 01:24 PM   #2
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
I think you have misunderstood something. The expressions you gave don't "return" that part- I think you left the replace text empty and replaced everything but the part you want to get by an empty string. What you're looking for are backreferences, for example, any previously matched group (stuff in parentheses) can be referenced by its number of occurence: In your example, using the expression
Code:
(.*?) - (.*?)
with the replace string
Code:
\1
would return the author name, the replace string
Code:
\2
would return the series name and index.
What you'll need to do, then, is to do two passes: The first one inserts the series info into the series field, the second removes the series info from the author field. For the first one, use the search expression
Code:
.*? - (.*?) (\d+)
and the replace text
Code:
\1 \[\2\]
(Hint: This should, from what I remember, immediately set the series index as well- the stuff in the square brackets. Also, be careful to set your destination field to series.) For the second pass, use the search expression
Code:
(.*?) - .*?
and the replacement text
Code:
\1
(The destination field should now be authors)

Caveat: I didn't test this, so it may go horribly wrong. Test on a small sample size before going fullscale.
You may be interested in the backreferences part of the regex tutorial.
Manichean is offline   Reply With Quote