Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-05-2011, 06:45 AM   #1
leria
Junior Member
leria began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Apr 2011
Device: none
regular expresion (clean the spaces)

sorry , it is my first regular espresion
the type of files are :

series numberofserie - title - author.epub
title - autor.epub


i have made this

^((?P<series>[^0-9-]*)(?P<series_index>[0-9]*)(\s-\s?)|)?( ??(\s*)(?P<title>[^_].*))(\s-\s)(\s?)(?P<author>[^_].*)

i want clean the left spaces of title , author and series.
i think i have made it for title and author , but i cant do it in the series , can you help me?
thank you a lot
leria is offline   Reply With Quote
Old 04-05-2011, 06:57 AM   #2
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
You need to add parts of the expression to basically suck up the spaces outside of your match groups:
Code:
^((?P<series>[^0-9-]*)\s*(?P<series_index>[0-9]+))?\s*(?P<title>[^_].*)\s*(?P<author>[^_].*)
ldolse is offline   Reply With Quote
Advert
Old 04-05-2011, 07:27 AM   #3
leria
Junior Member
leria began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Apr 2011
Device: none
thanks i think it works


^(\s*(?P<series>[^0-9-]*)(?P<series_index>[0-9]*)(\s-\s?)|)?( ??(\s*)(?P<title>[^_].*))(\s-\s)(?P<author>[^_].*)



but i have another problem

file type

serial serialnumber - title - autho.epub

example:
books of films 10 - Rambo - Silvester.epub > ok
books of films 10 - Rambo - Silvester.epub > ok
books of films - Rambo - Silvester.epub > ok
Rambo - Silvester.epub > ok
Rambo - Silvester.epub > ok

BUT
books of films 10 -Rambo - Silvester.epub >fail
if i have more than one space between the numbre and the "-" it fails

after so many changes I'm lost


done
let me know if you see an error

^(\s*(?P<series>[^0-9]*)(?P<series_index>[0-9]*)\s*(\s-\s)|)?( ??(\s*)(?P<title>[^_].*))(\s-\s)(?P<author>[^_].*)

thanks a lot

Last edited by leria; 04-05-2011 at 08:28 AM.
leria is offline   Reply With Quote
Old 04-05-2011, 09:03 AM   #4
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
I would think that you could replace \s*(\s-\s) with something like \s*-\s* to allow any number of spaces either side of the dash. The current expression REQUIRES there to be at least one space either side.
itimpi is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. PDF, 13th Dec 2010 BrianMartinez Other Books 0 12-13-2010 09:27 PM
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. 13th Dec 2010 BrianMartinez Kindle Books 0 12-13-2010 09:25 PM
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. 13th Dec 2010 BrianMartinez ePub Books 0 12-13-2010 09:23 PM
embedded spaces rikm Calibre 1 06-03-2010 03:08 PM
Non breaking spaces? troymc Sigil 6 05-22-2010 07:47 AM


All times are GMT -4. The time now is 12:54 AM.


MobileRead.com is a privately owned, operated and funded community.