Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 01-08-2010, 06:52 AM   #1
ghostyjack
Guru
ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.ghostyjack ought to be getting tired of karma fortunes by now.
 
ghostyjack's Avatar
 
Posts: 718
Karma: 1085610
Join Date: Mar 2009
Location: Bristol, England
Device: PRS-T1, 1825PT, Galaxy Tab, One X, TF700T, Aura HD, Nexus 7
Help with Regular Expressions

I keep hearing about regular expressions and have seen some of the regular expressions in threads on this site, but unfortunatly they doen't make a lot of sense.

Could someone explain to me just what they are and how to use them?

Also what would the benefit be in using them?
ghostyjack is offline   Reply With Quote
Old 01-08-2010, 08:30 AM   #2
rogue_ronin
Banned
rogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-books
 
Posts: 475
Karma: 796
Join Date: Sep 2008
Location: Honolulu
Device: Nokia 770 (fbreader)
It's basically recognizing patterns.

If you can tell a program to look for patterns, you can have the program change or record or reproduce or whatever you want it to do.

Typically, they're used for search and replace operations -- including replacing with nothing (thus deleting.)

Imagine you have a text file: in that file are recurring lines that have a single number (page numbers, for instance.) They don't add anything to an ebook, in fact they interrupt the reading experience:

Code:
blah blah blah I'm a great shaper of words blah
214
blahbety blah geflugehh cthulhu
Using regular expressions (regex) you can search for the pattern "any line that has only a number on it" and replace it with nothing. (That pattern might look like ^\d+\n or other variations. The ^ means "at the beginning of the line"; the \d means "digits"; the + means "one or more" and the \n means "carriage return". Together they identify the pattern "one or more digits occurring at the beginning of a line, followed immediately by a carriage return".

Once you get familiar with the symbols, you can identify any recurring pattern and, as you get more sophisticated, you can extract information from those patterns and restructure and replace it.

It's really worth learning, especially if you are doing proofreading and editing of texts.

m a r
rogue_ronin is offline   Reply With Quote
Advert
Old 01-08-2010, 12:04 PM   #3
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
Quote:
Originally Posted by ghostyjack View Post
Could someone explain to me just what they are and how to use them?
Wikipedia has a very nice article on them.
Valloric is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with regular expressions Manichean Conversion 10 02-03-2011 03:27 PM
Custom Regular Expressions for adding book information bigbot3 Calibre 1 12-25-2010 07:28 PM
Regular expressions, Calibre and you- an introduction (Archived) Manichean Conversion 80 11-11-2010 08:37 AM
Regular Expressions help needed Phil_C Workshop 20 10-03-2009 01:14 AM
BookDesigner v5 and regular expressions ShineOn Sony Reader 11 08-25-2008 05:06 PM


All times are GMT -4. The time now is 10:09 PM.


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