![]() |
#1 |
Junior Member
![]() 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 |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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>[^_].*) |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() 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. |
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,553
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.
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |