Mobileread
Splitting multiple author names - RegEx little modification?
#1  font332 11-04-2017, 11:30 AM
Hello

So the basic RegEx is:

Code
authors_split_regex = '(?i),?\\s+(and|with)\\s+'
and I have some authors separated by "; " e.g. "Author; Second Author; Third"

How for such case the RegEx could look like?
Reply 

#2  font332 05-25-2020, 07:19 AM
Bump
Reply 

#3  theducks 05-25-2020, 09:57 AM
Bumping is frowned upon.
Necro-bumping is really frowned upon
Reply 

#4  jhowell 05-25-2020, 10:00 AM
Waiting over two years for a response before bumping shows an incredible level of patience.
Reply 

#5  BetterRed 05-25-2020, 06:08 PM
Quote jhowell
Waiting over two years for a response before bumping shows an incredible level of patience.
↑ ↑ ↑ ✔

Or font332 was hibernating, as most of us have been forced/coerced into doing recently.

Hopefully a regex guru (which I'm not) will give font332 an answer to the question he/she posted in 2017.

Even Qt and MS are sometimes quicker than that

BR
Reply 

#6  davidfor 05-25-2020, 08:52 PM
With the emoticon, I can't decide if @font332 is being serious or not. But...

My first thought was simply:

Code
(?i),?\\s+(and|with|;)\\s+
But, there will probably not be any spacing before the semi-colon.

I think the following works:

Code
(?i),?(\\s*;\\s*|\\s+(?:and|with)\\s+)
I haven't done much testing with this. The only issue I can see is if you had "; and". In that case, the "and" would be part of the name.
Reply 

#7  font332 05-26-2020, 11:01 PM
Thanks everyone for the interest.

In fact I think I've probably solved my problem at that time, but then I lost my library and forgot the formula and regex also. It's been already few times in my life re-learning the regex, but we have to know when to say stop. That's partly why I bumped this dusty topic.

Thank you @davidfor for the formula, it probably doesn't work tho.
I say probably because the way how I checked this is that normally when we are typing the authors in author field and we type "&" symbol, calibre will start to give a list of suggestion for another author. This doesn't happen for ";" symbol.
I think anyway I will not make life more complicated then necessary and I will give up this idea and just convert and use for the future the "&" symbol.
Reply 

#8  davidfor 05-27-2020, 12:32 AM
Quote font332
Thank you @davidfor for the formula, it probably doesn't work tho.
I say probably because the way how I checked this is that normally when we are typing the authors in author field and we type "&" symbol, calibre will start to give a list of suggestion for another author. This doesn't happen for ";" symbol.
I think anyway I will not make life more complicated then necessary and I will give up this idea and just convert and use for the future the "&" symbol.
For typing into the author field it probably won't work. The "&" appears to be the trigger the end of an author and to show the drop-down for the next. I think the tweak is more for when calibre is parsing the full author string. Such as when getting the author from the metadata of an existing book. But, it also parses the author when save the changes in the metadata editor.
Reply 

#9  font332 05-28-2020, 12:47 AM
Thanks for clarification
Reply 

Today's Posts | Search this Thread | Login | Register