![]() |
#1 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Need help with a regex
Hi guys, I'm working on a dictionary for the kindle pw, but I need some help with the regular-expressions.
This is the regex: if the string "phrasal verb" is found I'd like to replace the "<b>" tag (also present in the same line) with this "<b>⌂ ". So there will be a tag, a symbol and an empty space. Any suggestions? Thanks. |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
The application you are using is important here, as there are multiple flavors or RegEx. The following should work:
look for: (\<b\>)(?=phrasal verb) Replace by: \1⌂ |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
The regex doesn't seem to work. I'm using notepad++.
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,724
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
You description of the string that you're looking for is somewhat vague. Assuming that you want to replace:
Code:
<b>take down</b> phrasal verb Code:
<b>⌂take down</b> phrasal verb
Code:
<b>(.*)<\/b> (phrasal verb) Code:
<b>⌂\1</b> \2 |
![]() |
![]() |
![]() |
#5 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,546
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Nothing works... Anyway, the regex should apply to lines similar to this:
Code:
<div class="dsl_m2"><font color="blue"><b>account for something</b></font><i><font color="green"> phrasal verb</font></i></div> |
![]() |
![]() |
![]() |
#7 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
It should work, but I know that the lookahead function has issues in Notepad++. It is the result of the RegEx library that NotePad++ uses, which is Boost. I love Notepad++, but its RegEx is full with bugs.
Last edited by Toxaris; 01-14-2014 at 09:12 AM. |
![]() |
![]() |
![]() |
#8 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Which software do you suggest?
|
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
I have no real alternative to be honest. I use Notepad++ myself. I avoid RegEx however in Notepad++.
|
![]() |
![]() |
![]() |
#10 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Ok, I've tried EditPad Lite since should have the best regex support, but the results are the same (for all the suggestions).
|
![]() |
![]() |
![]() |
#11 |
A curiosus lector!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
|
You can also try SynWrite: http://sourceforge.net/projects/synwrite/
|
![]() |
![]() |
![]() |
#12 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Nice app, but no luck
![]() |
![]() |
![]() |
![]() |
#13 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,724
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
It obviously won't work if there are other tags between the text in <b></b> tags and "phrasal verb," which you forgot to mention. BTW, regular expressions only work if the string that you're looking for has a predictable pattern. For more information see this tutorial website. |
|
![]() |
![]() |
![]() |
#14 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Sorry for not providing enough information, but I know very little of regular-expressions
![]() |
![]() |
![]() |
![]() |
#15 | |
Klak
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 174
Karma: 150374
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
|
Quote:
i am not sure how good is python regex library? |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with some regex | Chaos_Therum | Library Management | 1 | 12-28-2013 11:20 AM |
Regex help | paulfiera | Sigil | 4 | 06-14-2012 07:55 AM |
RegEx Help | ghostyjack | Workshop | 4 | 03-22-2012 09:24 AM |
Help me with regex please. | eVrajka | Library Management | 5 | 08-15-2011 12:17 PM |
regex help please | thevoiceofcheese | Calibre | 2 | 08-01-2011 11:27 PM |