![]() |
#1 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Mar 2018
Location: Vancouver, BC
Device: Kindle Voyage
|
![]()
I see that the Sigil Clip Editor has some basic regex (e.g., the first numbered group
Code:
\1 Code:
\U Specifically, I am wondering if I can easily parse the selected text using regex pattern and replace it with some other text using the Clips functionality. |
![]() |
![]() |
![]() |
#3 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
Quote:
Search: ([abc]+)([def]+)([hij]+) Replace: \1\2\3 Each Regex within the parentheses becomes its own "group", which you can then replace using \1, \2, \3, [...]. acabacdhh \U tells regex to "uppercase everything beyond this point". So let's say you only wanted to uppercase the groups 2 and 3: Search: ([abc]+)([def]+)([hij]+) Replace: \1\U\2\3 acabacDHH Side Note: See "Use Parentheses for Grouping and Capturing" on Regular-Expressions.info and "Numbered Backreferences" for more information. |
||
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Mar 2018
Location: Vancouver, BC
Device: Kindle Voyage
|
Thank you both for your assistance.
I am specifically interested in constructing a Sigil Clip that is able to manipulate selected text according to a pre-defined pattern. However, I am not sure where I am supposed to put the pattern that I am anticipating when using Clip function. I know how to do this regex using find/replace, but not with Clip. Where do I specify the find pattern? Last edited by mavaddat; 02-07-2019 at 03:48 PM. |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
The way that Sigil Clips works is you highlight text, and then you apply the Clip.
Your highlighted text will be grouped into: \1 So let's say you highlight: Code:
This is text I |want in italics|.
Code:
This is text I <i>want in italics</i>.
Like I created this Sigil Clip for myself: Code:
<div class="chart"> <div class="single-chart"> <div class="chart-title"></div> <div class="image"></div> <div class="chart-caption"></div> </div> </div> To do more advanced Search/Replace using Regex, you use Tools > Saved Searches. Last edited by Tex2002ans; 02-07-2019 at 05:31 PM. |
![]() |
![]() |
![]() |
#7 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,054
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
But you can replace selected (highlighted) text with a clip.
Here is what I use to uppercase a selection \U\1\E |
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
|
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Mar 2018
Location: Vancouver, BC
Device: Kindle Voyage
|
Thanks all! Tex2002ans and Doitsu's responses answer the question for me.
|
![]() |
![]() |
![]() |
Tags |
clips, clips editor, regex, sigil |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Editor: conversion to lowercase with regex | Sam Sahara | Editor | 1 | 05-13-2018 06:51 AM |
RegEx: anchor problem in editor | DrChiper | Editor | 4 | 04-09-2018 09:15 AM |
Error with Clip Editor | cleocalliope | Sigil | 15 | 08-14-2015 01:47 AM |
regex in calibre editor | mrmikel | Editor | 2 | 02-01-2014 10:39 AM |
Guide to Regex in Calibre Editor vs Notepad++ | Agama | Editor | 6 | 12-23-2013 05:10 AM |