Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 01-14-2014, 05:16 AM   #1
mobiuser
Member
mobiuser began at the beginning.
 
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.
mobiuser is offline   Reply With Quote
Old 01-14-2014, 06:21 AM   #2
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
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⌂
Toxaris is offline   Reply With Quote
Old 01-14-2014, 07:12 AM   #3
mobiuser
Member
mobiuser began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
The regex doesn't seem to work. I'm using notepad++.
mobiuser is offline   Reply With Quote
Old 01-14-2014, 07:27 AM   #4
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by mobiuser View Post
The regex doesn't seem to work. I'm using notepad++.
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
with

Code:
<b>take down</b> phrasal verb
You could search for:

Code:
<b>(.*)<\/b> (phrasal verb)
and replace it with:

Code:
<b>⌂\1</b> \2
Doitsu is offline   Reply With Quote
Old 01-14-2014, 07:43 AM   #5
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Doitsu View Post
You could search for:

Code:
<b>(.*)<\/b> (phrasal verb)
and replace it with:

Code:
<b>⌂\1</b> \2
Or search:

Code:
(<b>)(.*<\/b> phrasal verb)
Replace:

Code:
\1⌂\2
Jellby is offline   Reply With Quote
Old 01-14-2014, 08:03 AM   #6
mobiuser
Member
mobiuser began at the beginning.
 
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>
mobiuser is offline   Reply With Quote
Old 01-14-2014, 09:06 AM   #7
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by mobiuser View Post
The regex doesn't seem to work. I'm using notepad++.
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.
Toxaris is offline   Reply With Quote
Old 01-14-2014, 09:19 AM   #8
mobiuser
Member
mobiuser began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
Which software do you suggest?
mobiuser is offline   Reply With Quote
Old 01-14-2014, 11:00 AM   #9
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
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++.
Toxaris is offline   Reply With Quote
Old 01-14-2014, 11:14 AM   #10
mobiuser
Member
mobiuser began at the beginning.
 
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).
mobiuser is offline   Reply With Quote
Old 01-14-2014, 11:23 AM   #11
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
You can also try SynWrite: http://sourceforge.net/projects/synwrite/
Arios is offline   Reply With Quote
Old 01-14-2014, 11:47 AM   #12
mobiuser
Member
mobiuser began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2013
Device: kindle pw
Nice app, but no luck
mobiuser is offline   Reply With Quote
Old 01-14-2014, 12:17 PM   #13
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by mobiuser View Post
Ok, I've tried EditPad Lite since should have the best regex support, but the results are the same (for all the suggestions).
That's because you initially provided not enough information about the string to look for and the replacement. For example, my suggestions worked just fine for the specific string that I assumed you were looking for.

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.
Doitsu is offline   Reply With Quote
Old 01-14-2014, 01:28 PM   #14
mobiuser
Member
mobiuser began at the beginning.
 
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?
mobiuser is offline   Reply With Quote
Old 01-15-2014, 02:10 PM   #15
najgori
Klak
najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'najgori gives new meaning to the word 'superlative.'
 
najgori's Avatar
 
Posts: 174
Karma: 150374
Join Date: Sep 2011
Location: Belgrade, Serbia
Device: many
Quote:
Originally Posted by Toxaris View Post
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.
i have used python plugin for notepad++ and python regular expression replace, for complex corrections in html.

i am not sure how good is python regex library?
najgori is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 03:04 PM.


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