![]() |
#1 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2019
Device: none
|
Replacing //.+// with <i>.+</i>
So in an ebook I'm converting from html, I need to replace all the text between "//" with the same text, but italics tags in place of the slashes.
I've spent a few hours mashing my face into learning regex and I can't figure out what seems like a simple task. I even tried in Word, and couldn't manage it there either. Can anyone help? For Example: // How is this possible? // I wondered to myself. // I simply can't see how to do it. // Needs to become:<i>How is this possible?</i> I wondered to myself. <i>I simply can't see how to do it.</i> Or It's all over my head. // This is why I got a C in compsci. // I hope someone can help me. Needs to become:It's all over my head. <i>This is why I got a C in compsci.</i> I hope someone can help me.
|
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Try:
Code:
\/\/\s(.*?)\s\/\/ With the replacement: Code:
<i>\1</i> Code:
\/\/\s*(.*?)\s*\/\/ Last edited by davidfor; 08-04-2019 at 10:04 PM. Reason: Fixing second example. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Quote:
Code:
\/\/\s*(.*?)\s*\/\/ |
|
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2019
Device: none
|
Ty :D
![]() Code:
\/\/\s*(.*?)\s*\/\/ Code:
<i>\1</i> Thank you both so much! |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2019
Device: none
|
A Little Tweak
Looks like I spoke too soon, none of the expressions caught all of the //. However, I did figure a solution, so if you need something similar and the prior answers don't work quite right, try this:
Code:
//\s*(.*?)\s*\/\D It wasn't flawless, it would catch: Code:
//Me? You can't be me. <i class="calibre4">I'm</i> me.//
Code:
// Could
it be? // he asked himself, // could it possibly be after so,
so very long? //
Code:
(all text until prior //) He projected as strongly as he could. // Center, C'mon. You can do this. You CAN. //
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PRS-T1 Replacing screen | dave45 | Sony Reader | 4 | 09-06-2013 11:07 AM |
Replacing the battery | msoulier | Kobo Reader | 2 | 09-28-2012 09:24 PM |
Replacing code without replacing text? | ElMiko | Sigil | 6 | 11-30-2011 08:14 PM |
Replacing my Hanlin V3 | maddz | Which one should I buy? | 0 | 11-25-2010 04:14 AM |
Replacing ¬ | PieOPah | Workshop | 5 | 12-17-2008 04:25 PM |