01-14-2014, 05:16 AM | #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. |
01-14-2014, 06:21 AM | #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⌂ |
01-14-2014, 07:12 AM | #3 |
Member
Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
The regex doesn't seem to work. I'm using notepad++.
|
01-14-2014, 07:27 AM | #4 |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
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 |
01-14-2014, 07:43 AM | #5 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
01-14-2014, 08:03 AM | #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> |
01-14-2014, 09:06 AM | #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. |
01-14-2014, 09:19 AM | #8 |
Member
Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Which software do you suggest?
|
01-14-2014, 11:00 AM | #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++.
|
01-14-2014, 11:14 AM | #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).
|
01-14-2014, 11:23 AM | #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/
|
01-14-2014, 11:47 AM | #12 |
Member
Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
|
Nice app, but no luck
|
01-14-2014, 12:17 PM | #13 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
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. |
|
01-14-2014, 01:28 PM | #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 . Is there anything I can do at this point?
|
01-15-2014, 02:10 PM | #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? |
|
|
Similar Threads | ||||
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 |