Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 10-20-2021, 05:03 PM   #1
Hortensia
Enthusiast
Hortensia began at the beginning.
 
Posts: 30
Karma: 10
Join Date: Jul 2021
Device: Kindle Paperwhite, Kobo Libra 2
Search and Repace in comma separated list

Using Search and Replace, I am trying to clean up a custom column with pairings but I cannot manage to write the correct regex.

The input data is as follow: "A/B, C/D, E/F (mentioned), G/H (mentioned), I/J".
The objective is to remove the pairing(s) which are only mentionned. I would like the following output: "A/B, C/D, IJ".

I tried with this regex:
Code:
,([^&]+)/([^&]+)\s\(mentioned\)
However, the output is: "A/B, I/J".

How to write the regex so that commas are not included in the
Code:
([^&]+)
component?
Hortensia is offline   Reply With Quote
Old 10-20-2021, 05:30 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,818
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
remember ( are captures ), so they need to be escaped \( and \)
So try this
(.+?),\w/\w\s*\(mentioned\),(.+?)
Replace is
\1,\2

NOT TESTED
theducks is offline   Reply With Quote
Old 10-20-2021, 05:47 PM   #3
Hortensia
Enthusiast
Hortensia began at the beginning.
 
Posts: 30
Karma: 10
Join Date: Jul 2021
Device: Kindle Paperwhite, Kobo Libra 2
Thank you, the \w was the key!

The final solution is:
Code:
,\s\w+/\w+\s\(mentioned\)
which gives: "A/B, C/D, I/J" as needed.

Last edited by Hortensia; 10-20-2021 at 06:14 PM.
Hortensia is offline   Reply With Quote
Reply

Tags
regex, search and replace


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Save ONLY Book List Vandy Calibre 1 01-18-2018 01:53 PM
Custom column - Comma separated text MerlinMama Library Management 4 09-17-2015 02:34 PM
How do I repace a Style Sheet? phossler Editor 13 12-24-2013 11:43 AM
Multiple comma separated values in custom column? silentguy Library Management 8 04-19-2011 05:10 AM
Switching author name from comma separated to first last kbaggs Library Management 1 01-30-2011 03:36 PM


All times are GMT -4. The time now is 07:45 AM.


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