문제

I`m trying to setup my calibre (calibre-ebook.com) to automatic get data from imported pdf files into library. Usually i name my files this way:

Author. Title. Local. Publisher. Published. ISBN.pdf

Example:

C:\Test\RANCIÊRE, Jacques. O mestre ignorante. Belo Horizonte. Autêntica. 2010. 978-85-7526-045-6.pdf


I`m stuck trying get the first paramenter: Author, using the regex:

([^\\]+)\.

I`m getting this value:

RANCIÊRE, Jacques. O mestre ignorante. Belo Horizonte. Autêntica. 2010. 978-85-7526-045-6


Since regex read from left to right isn`t to stop on first dot (.) from .?

The desired value on this example is:

RANCIÊRE, Jacques

Any hint for the other fields? Example for Title the desired value is:

O mestre ignorante

Thanks in advice!!!

도움이 되었습니까?

해결책

^.+?\. will get you the C:\Test\RANCIÊRE, Jacques.

it means get the all characters before the first dot.

if you want only RANCIÊRE, Jacques than use:

(?!(.*\\))(.+?\.)

will give you RANCIÊRE, Jacques.

다른 팁

Regex capturing is greedy, meaning it tries to get the largest match as possible. Try the non-greedy version:

([^\\]+?)\.

Note the only difference is the addition of a ?.

Afterwards, you should be able to retrieve the author's name ("RANCIÊRE, Jacques") with just \1.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top