View Single Post
Old 03-18-2012, 02:04 PM   #1
charlweed
Enthusiast
charlweed began at the beginning.
 
Posts: 27
Karma: 30
Join Date: Jul 2011
Device: none
Replace field with match or empty string?

I want to “replace” a field with a string from the title is it is found, or an empty string if it is not.
I currently have mixed titles like:

Anne McCaffrey - Pern 10 - The Renegades of Pern
Generation Warriors
The Mystery of Ireta: Dinosaur Planet & Dinosaur Planet Survivors
Anne McCaffrey - Tsw 7 - Ship That Returned

I want to pick out “Pern 10” from the first example, and “Tsw 7” from the fourth example, and write them to the series field. How can I do this?

My current problem is that if there is no match for my group expression, the UI reports an “unmatched group” error, and refuses to proceed.
So how can I create a group that “always matches” but contains an empty string if it’s really not there?
Here is my current, erroneous expression,

(((P<author>[^-]*?)- )?((?P<series>\w+)\W*(?P<series_index>\d*)\s-))?(?P<title>.*)

The only field I want at the moment is \g<series>

Thanks!
charlweed is offline   Reply With Quote