I received my author copy of “Regulární výrazy—Kuchařka programátora” last week. This is the Czech translation of Regular Expressions Cookbook. You can buy Regulární výrazy Kuchařka programátora from the publisher cpress.cz or any bookstore that sells Czech language books. Ask for ISBN 978-80-251-1935-8.
While the Russian, German, and Japanese translations are full translations, the Czech translation is an abridged translation. It has only 7 chapters compared to 8 with the original English edition. The last chapter, “Markup and Data Interchange”, was omitted. This chapter has examples on using regular expressions on HTML and XML files and demonstrates some more complex regex techniques. All the other chapters were translated completely.
A RegexBuddy user told me that he couldn’t easily find a detailed explanation of the replacement text syntax supported by the String.replace() function in JavaScript. I had to admin that my own web page about JavaScript’s regular expression support was also lacking. I’ve now added a new Replacement Syntax section that has all the details. I’ll summarize it here:
$1: Text matched by the first capturing group or the literal text $1 if the regex has no capturing groups.
$99: Text matched by the 99th capturing group if the regex has 99 or more groups. Text matched by the 9th capturing group followed by a literal 9 if the regex has 9 or more but less than 99 groups. The literal text $99 if the regex has fewer than 9 groups.
$+: Text matched by the highest-numbered capturing group. Replaced with nothing if the highest-numbered group didn’t participate in the match.
$&: Text matched by the entire regex. You cannot use $0 for this.
$` (backtick): Text to the left of the regex match.
$' (single quote): Text to the right of the regex match.
$_: The entire subject string.
I’ve just been informed that O’Reilly will publish the Japanese translation of Regular Expressions Cookbook on 14 April. The Japanese title is 正規表現クックブック. You can order 正規表現クックブック from O’Reilly, Amazon.co.jp (free shipping in Japan), or wherever Japanese language technical books are sold.
You may have heard some people say that most book authors never get any royalties. That’s not true because most authors get an advance royalty that is paid before the book is published. That’s the author’s main incentive for writing the book, at least as far as money is concerned. (If money is your main concern, don’t write books.)
What is true is that most authors never see any money beyond the advance royalty. Royalty rates are very low. A 10% royalty of the publisher’s price is considered normal. The publisher’s price is usually 45% of the retail price. So if you pay full price in a bookstore, the author gets 4.5% of your money. If there’s more than one author, they split the royalty. It doesn’t take a math degree to figure out that a book needs to sell quite a few copies for the royalty to add up to a meaningful amount of money.
But Steven and I must have done something right. Regular Expressions Cookbook is in the money. My royalty statement for the 3rd quartier of 2009, which is the 2nd quarter that the book was on the market, came with a check. I actually received it last month but didn’t get around to blogging about. The amount of the check is insignificant. The point is that the balance is no longer negative. I’m taking this opportunity to pat myself and my co-author on the back.
To celebrate the occassion O’Reilly has offered to sponsor a give-away of five (5) copies of Regular Expressions Cookbook. These are the rules of the game:
- You must post a comment to this blog article including your actual name and actual email address. Names are published, email addresses are not.
- Comments are moderated by myself (Jan Goyvaerts). If I consider a comment to be offensive or spam it will not be published and not be eligible for any prize.
- If you don’t know what to say in the comment, just wish me a happy 100000nd birthday, so I don’t have to feel so bad about entering the 6-bit era.
- Each person commenting has only one chance to win, regardless of the number of comments posted.
- O’Reilly will be provided with the names and email addresses of the winners (and those email addresses only) in order to arrange delivery.
- Each winner can choose to receive a printed copy or ebook (DRM-free PDF). If you choose the printed book, O’Reilly pays for shipping to anywhere in the world but not for any duties or taxes your country may impose on books imported from the USA. If you choose the ebook, you’ll need to create an O’Reilly account that is then granted access to the PDF download. You can make your choice after you’ve won, so it doesn’t influence your chance of winning.
- Contest ends 28 February 2010, GMT+7 (Thai time).
Chosen by five calls to Random(78)+1 in Delphi 2010, the winners are:
- 48: Xiaozu
- 45: David Chisholm
- 19: Miquel Burns
- 33: Aaron Rice
- 17: David Laing
Thanks to everybody who participated. The winners have been notified by email on how to collect their prize.