Debian Codegraph @

translations/manual/ja/regexp.po

raw
1 # SOME DESCRIPTIVE TITLE.
2 # Copyright (C) Kovid Goyal
3 # This file is distributed under the same license as the calibre package.
4 #
5 # Translators:
6 # akihiko tanae (tanaeakihiko), 2025-2026
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: calibre\n"
10 "Report-Msgid-Bugs-To: \n"
11 "POT-Creation-Date: 2026-02-22 09:00+0000\n"
12 "PO-Revision-Date: 2014-06-17 08:35+0000\n"
13 "Last-Translator: akihiko tanae (tanaeakihiko), 2025-2026\n"
14 "Language-Team: Japanese (http://app.transifex.com/calibre/calibre/language/ja/)\n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18 "Language: ja\n"
19 "Plural-Forms: nplurals=1; plural=0;\n"
20
21 #: ../../../__w/calibre/calibre/manual/regexp.rst:4
22 msgid "All about using regular expressions in calibre"
23 msgstr "calibre で正規表現を利用するにあたって重要なこと"
24
25 #: ../../../__w/calibre/calibre/manual/regexp.rst:6
26 msgid ""
27 "Regular expressions are features used in many places in calibre to perform "
28 "sophisticated manipulation of e-book content and metadata. This tutorial is "
29 "a gentle introduction to getting you started with using regular expressions "
30 "in calibre."
31 msgstr "正規表現は、電子書籍のコンテンツと書誌に対して高度な操作を実行するために calibre のあちこちで使われている機能です。このチュートリアルは、calibre で正規表現を使い始めるための簡単な入門書です。"
32
33 #: ../../../__w/calibre/calibre/manual/regexp.rst:11
34 msgid "Contents"
35 msgstr "目次"
36
37 #: ../../../__w/calibre/calibre/manual/regexp.rst:14
38 msgid "First, a word of warning and a word of courage"
39 msgstr "最初に、警告と激励"
40
41 #: ../../../__w/calibre/calibre/manual/regexp.rst:16
42 msgid ""
43 "This is, inevitably, going to be somewhat technical- after all, regular "
44 "expressions are a technical tool for doing technical stuff. I'm going to "
45 "have to use some jargon and concepts that may seem complicated or "
46 "convoluted. I'm going to try to explain those concepts as clearly as I can, "
47 "but really can't do without using them at all. That being said, don't be "
48 "discouraged by any jargon, as I've tried to explain everything new. And "
49 "while regular expressions themselves may seem like an arcane, black magic "
50 "(or, to be more prosaic, a random string of mumbo-jumbo letters and signs), "
51 "I promise that they are not all that complicated. Even those who understand "
52 "regular expressions really well have trouble reading the more complex ones, "
53 "but writing them isn't as difficult- you construct the expression step by "
54 "step. So, take a step and follow me into the rabbit hole."
55 msgstr "必然的に、これは技術的なものになります。何と言っても正規表現というものは、技術的なことを行うための技術的なツールなのです。使わざるを得ない専門用語や概念が、複雑または難解に見えるかもしれません。そうした概念について、可能な限りわかりやすく説明していくつもりですが、専門用語をまったく使わずに説明するのは無理があります。そうは言っても、専門用語を見てもがっかりしないでください。新しいことはすべて説明するよう努めました。そして正規表現そのものがあやしげな黒魔術のように見えるかもしれませんが (もっとぶっちゃけると、わけのわからないランダムな文字と記号の羅列にしか見えないかもしれませんが) 決してそれほど複雑なものではありません。正規表現をきちんと理解している人でも複雑なものを解読するのは困難ですが、書くのはそれほど難しいことではありません。一歩ずつ段階的に構築していけばよいのです。ですから、一緒に最初の一歩を踏み出してみましょう。"
56
57 #: ../../../__w/calibre/calibre/manual/regexp.rst:19
58 msgid "Where in calibre can you use regular expressions?"
59 msgstr "calibre のどこで正規表現を使えますか?"
60
61 #: ../../../__w/calibre/calibre/manual/regexp.rst:21
62 msgid ""
63 "There are a few places calibre uses regular expressions. There's the "
64 ":guilabel:`Search & replace` in conversion options, metadata detection from "
65 "filenames in the import settings and Search & replace when editing the "
66 "metadata of books in bulk. The calibre book editor can also use regular "
67 "expressions in its :guilabel:`Search and replace` feature. Finally, you can "
68 "use regular expressions when searching the calibre book list and when "
69 "searching inside the calibre E-book viewer."
70 msgstr "calibre が正規表現を使用する場所はいくつかあります。それは変換オプションの中の :guilabel:`検索 & 置換` 、インポート設定の中にあるファイル名からの書誌の検出、書誌を一括編集するときの検索 & 置換です。calibre の書籍エディタは、:guilabel:`検索と置換` 機能の中で正規表現を使用することができます。最後に、calibre の本の一覧を検索するときや calibre の電子書籍ビューアの中で検索をするときにも正規表現を使用できます。"
71
72 #: ../../../__w/calibre/calibre/manual/regexp.rst:30
73 msgid "What on earth *is* a regular expression?"
74 msgstr "正規表現とはいったい何ですか?"
75
76 #: ../../../__w/calibre/calibre/manual/regexp.rst:32
77 msgid ""
78 "A regular expression is a way to describe sets of strings. A single regular "
79 "expression can *match* a number of different strings. This is what makes "
80 "regular expression so powerful -- they are a concise way of describing a "
81 "potentially large number of variations."
82 msgstr "正規表現とは、文字列のセットを表現する方法です。ひとつの正規表現で、いくつもの異なる文字列に *マッチ* させることができます。これが正規表現を非常に強力にしているものです。潜在的に数多くのバリエーションを表現する、簡潔な方法なのです。"
83
84 #: ../../../__w/calibre/calibre/manual/regexp.rst:34
85 msgid ""
86 "I'm using string here in the sense it is used in programming languages: a "
87 "string of one or more characters, characters including actual characters, "
88 "numbers, punctuation and so-called whitespace (linebreaks, tabulators etc.)."
89 " Please note that generally, uppercase and lowercase characters are not "
90 "considered the same, thus \"a\" being a different character from \"A\" and "
91 "so forth. In calibre, regular expressions are case insensitive in the Search"
92 " bar, but not in the conversion options. There's a way to make every regular"
93 " expression case insensitive, but we'll discuss that later. It gets "
94 "complicated because regular expressions allow for variations in the strings "
95 "it matches, so one expression can match multiple strings, which is why "
96 "people bother using them at all. More on that in a bit."
97 msgstr "ここでは文字列という言葉をプログラミング言語で使用される意味で使っています。文字列とは、ひとつ以上の文字で、実際の文字、数字、句読点、およびいわゆる空白と呼ばれるもの (改行、タブなど) を含みます。通常、大文字と小文字は同じものとはみなされないため、たとえば \"a\" は \"A\" とは別の文字として扱われます。calibre では、検索バーでは正規表現は大文字と小文字を区別しませんが、変換オプションでは区別します。すべての正規表現で大文字と小文字を区別しなくする設定もありますが、それは後で説明します。正規表現はマッチする文字列にバリエーションを許しているために複雑になり、ひとつの表現が複数の文字列にマッチします。人々が正規表現を使用したがらないのは、それが理由です。"
98
99 #: ../../../__w/calibre/calibre/manual/regexp.rst:37
100 msgid "Care to explain?"
101 msgstr "説明してもらえますか?"
102
103 #: ../../../__w/calibre/calibre/manual/regexp.rst:39
104 msgid ""
105 "Well, that's why we're here. First, this is the most important concept in "
106 "regular expressions: *A string by itself is a regular expression that "
107 "matches itself*. That is to say, if I wanted to match the string ``\"Hello, "
108 "World!\"`` using a regular expression, the regular expression to use would "
109 "be ``Hello, World!``. And yes, it really is that simple. You'll notice, "
110 "though, that this *only* matches the exact string ``\"Hello, World!\"``, not"
111 " e.g. ``\"Hello, wOrld!\"`` or ``\"hello, world!\"`` or any other such "
112 "variation."
113 msgstr "それこそが目的です。まず、正規表現において最も重要な概念ですが、 *ある文字列は、その文字列自体にマッチする正規表現* です。つまり ``\"Hello, World!\"`` という文字列に正規表現を使ってマッチさせたい場合、使用すべき正規表現は ``Hello, World!`` です。そうです、それくらい簡単なことなのです。ただし、これがマッチするのは ``\"Hello, World!\"`` という文字列 *だけ* です。つまり、``\"Hello, wOrld!\"`` や ``\"hello, world!\"`` など他のバリエーションにはマッチしません。"
114
115 #: ../../../__w/calibre/calibre/manual/regexp.rst:42
116 msgid "That doesn't sound too bad. What's next?"
117 msgstr "そんなに悪くありません。次は?"
118
119 #: ../../../__w/calibre/calibre/manual/regexp.rst:44
120 msgid ""
121 "Next is the beginning of the really good stuff. Remember where I said that "
122 "regular expressions can match multiple strings? This is where it gets a "
123 "little more complicated. Say, as a somewhat more practical exercise, the "
124 "e-book you wanted to convert had a nasty footer counting the pages, like "
125 "\"Page 5 of 423\". Obviously the page number would rise from 1 to 423, thus "
126 "you'd have to match 423 different strings, right? Wrong, actually: regular "
127 "expressions allow you to define sets of characters that are matched: To "
128 "define a set, you put all the characters you want to be in the set into "
129 "square brackets. So, for example, the set ``[abc]`` would match either the "
130 "character \"a\", \"b\" or \"c\". *Sets will always only match one of the "
131 "characters in the set*. They \"understand\" character ranges, that is, if "
132 "you wanted to match all the lower case characters, you'd use the set "
133 "``[a-z]`` for lower- and uppercase characters you'd use ``[a-zA-Z]`` and so "
134 "on. Got the idea? So, obviously, using the expression ``Page [0-9] of 423`` "
135 "you'd be able to match the first 9 pages, thus reducing the expressions "
136 "needed to three: The second expression ``Page [0-9][0-9] of 423`` would "
137 "match all two-digit page numbers, and I'm sure you can guess what the third "
138 "expression would look like. Yes, go ahead. Write it down."
139 msgstr "次は、本当に使えるもののさわりの部分です。正規表現が複数の文字列にマッチする可能性があると説明したのを覚えていますか? これが少し複雑になっていくところです。たとえば、もっと実用的な例として、変換したい電子書籍のフッタ部分に \"Page 5 of 423\" のように厄介なページカウントがあったとします。明らかにページ数は 1 から 423 まで順に増えていきますから、423 通りの異なる文字列にマッチさせる必要があります。そうでしょう? しかし、実は必要ないのです。正規表現を使えば、マッチする文字のセットを定義することが可能です。セットを定義するには、マッチさせたいすべての文字を角カッコの中に羅列します。したがってたとえば ``[abc]`` というセットは \"a\", \"b\" または \"c\" という文字にマッチします。*セットは、常にセット内の文字のひとつとだけマッチします*。セットは文字の範囲を \"理解\" します。つまり、すべての小文字とマッチさせたい場合には ``[a-z]`` を使用し、小文字と大文字にマッチさせたい場合には ``[a-zA-Z]`` を使用するといった具合です。理解できましたか? したがって ``Page [0-9] of 423`` という表現を使用すれば、言うまでもなく最初の 9 ページにマッチさせることができます。こうして必要な表現を 3 個に絞ることができます。2 個目の表現は ``Page [0-9][0-9] of 423`` で、すべての 2 桁のページにマッチします。3 個目の表現をどうすればよいかは、もうおわかりですね。はい、どうぞ。書いてみてください。"
140
141 #: ../../../__w/calibre/calibre/manual/regexp.rst:47
142 msgid "Hey, neat! This is starting to make sense!"
143 msgstr "すごい! 意味がわかってきました!"
144
145 #: ../../../__w/calibre/calibre/manual/regexp.rst:49
146 msgid ""
147 "I was hoping you'd say that. But brace yourself, now it gets even better! We"
148 " just saw that using sets, we could match one of several characters at once."
149 " But you can even repeat a character or set, reducing the number of "
150 "expressions needed to handle the above page number example to one. Yes, ONE!"
151 " Excited? You should be! It works like this: Some so-called special "
152 "characters, \"+\", \"?\" and \"*\", *repeat the single element preceding "
153 "them*. (Element means either a single character, a character set, an escape "
154 "sequence or a group (we'll learn about those last two later)- in short, any "
155 "single entity in a regular expression). These characters are called "
156 "wildcards or quantifiers. To be more precise, \"?\" matches *0 or 1* of the "
157 "preceding element, \"*\" matches *0 or more* of the preceding element and "
158 "\"+\" matches *1 or more* of the preceding element. A few examples: The "
159 "expression ``a?`` would match either \"\" (which is the empty string, not "
160 "strictly useful in this case) or \"a\", the expression ``a*`` would match "
161 "\"\", \"a\", \"aa\" or any number of a's in a row, and, finally, the "
162 "expression ``a+`` would match \"a\", \"aa\" or any number of a's in a row "
163 "(Note: it wouldn't match the empty string!). Same deal for sets: The "
164 "expression ``[0-9]+`` would match *every integer number there is*! I know "
165 "what you're thinking, and you're right: If you use that in the above case of"
166 " matching page numbers, wouldn't that be the single one expression to match "
167 "all the page numbers? Yes, the expression ``Page [0-9]+ of 423`` would match"
168 " every page number in that book!"
169 msgstr "そう言ってくれると思っていました。でも気を引き締めてください。まだまだよくなって行きます。セットを使用すると、いくつかの文字を一度にマッチさせることができることがわかりました。しかし文字やセットを繰り返すことも可能なのです。そうすることで、上の例でページ番号を扱う正規表現をひとつに減らすことができます。そうです、たったの 1 個です。わくわくしますか? きっとするでしょう。それは次のように機能します: 特殊文字と呼ばれるもの一部、\"+\", \"?\" および \"*\" は *それに続くひとつの要素を繰り返します* 。(要素とは、ひとつも文字、ひとつの文字セット、エスケープシーケンス、またはグループのことです。最後の 2 つについては後で説明します。要するに、正規表現の中にある任意のひとつのエンティティです) このような文字は、ワイルドカードまたは量指定子と呼ばれます。具体的に言うと、\"?\" は直前の要素が *0 または 1* 個のものにマッチし、\"*\" は直前の要素が *0 個以上* のものにマッチし、\"+\" は直前の要素が *1 個以上* のものにマッチします。いくつか例を示しましょう。正規表現 ``a?`` は \"\" (つまり空の文字列で、このケースでは特に便利ではありません) または \"a\" にマッチし、``a*`` は \"\", \"a\", \"aa\", および a が連続して並んでいる限り何個でもマッチし、正規表現 ``a+`` は \"a\", \"aa\", および a が連続して並んでいる限り何個でもマッチします (ただし空の文字列にはマッチしません)。セットについても同じことが言えます。正規表現 ``[0-9]+`` は *すべての整数* にマッチします。さてここで、読者が何を考えているか筆者にはわかります。そしてそれは間違っていません。もしこれを上記のケースでページ番号のマッチに使用したら、ひとつの正規表現だけですべてのページにマッチするのではないか? そのとおり、``Page [0-9]+ of 423`` は本の中のすべてのページにマッチするでしょう。"
170
171 #: ../../../__w/calibre/calibre/manual/regexp.rst:52
172 msgid ""
173 "A note on these quantifiers: They generally try to match as much text as "
174 "possible, so be careful when using them. This is called \"greedy "
175 "behaviour\"- I'm sure you get why. It gets problematic when you, say, try to"
176 " match a tag. Consider, for example, the string ``\"<p "
177 "class=\"calibre2\">Title here</p>\"`` and let's say you'd want to match the "
178 "opening tag (the part between the first pair of angle brackets, a little "
179 "more on tags later). You'd think that the expression ``<p.*>`` would match "
180 "that tag, but actually, it matches the whole string! (The character \".\" is"
181 " another special character. It matches anything *except* linebreaks, so, "
182 "basically, the expression ``.*`` would match any single line you can think "
183 "of). Instead, try using ``<p.*?>`` which makes the quantifier ``\"*\"`` non-"
184 "greedy. That expression would only match the first opening tag, as intended."
185 " There's actually another way to accomplish this: The expression "
186 "``<p[^>]*>`` will match that same opening tag- you'll see why after the next"
187 " section. Just note that there quite frequently is more than one way to "
188 "write a regular expression."
189 msgstr "量指定子に関する注意点: 量指定子は通常、可能な限り多くのテキストとマッチさせようとします。ですから使用する場合には注意してください。これは \"貪欲な動作\" と呼ばれます。もちろん理由はおわかりですね。これは、たとえばタグをマッチさせようとする場合などに問題が起きます。たとえば、文字列 ``\"<p class=\"calibre2\">Title here</p>\"`` から開きタグ (山カッコで囲まれた最初のパーツ、タグについては後述します) にマッチさせたいとしましょう。正規表現 ``<p.*>`` がそのタグにマッチすると思うかもしれませんが、実際には文字列全体にマッチしてしまいます。(文字 \".\" もまた特殊文字です。これは改行 *以外* のすべての文字にマッチします。したがって、基本的には正規表現 ``.*`` はどのような内容でも 1 行すべてにマッチします) 代わりに ``<p.*?>`` を試してみましょう。これは量指定子 ``\"*\"`` を貪欲ではなくします。この正規表現は、意図したとりに最初のタグにだけマッチします。実はこれにはもうひとつ別のやり方があります。正規表現 ``<p[^>]*>`` も同様に最初の開きタグにマッチします。理由は次の章以降にわかるでしょう。ここでは、しばしば正規表現の書き方はひとつではないということを心に留めておいてください。"
190
191 #: ../../../__w/calibre/calibre/manual/regexp.rst:56
192 msgid ""
193 "Well, these special characters are very neat and all, but what if I wanted "
194 "to match a dot or a question mark?"
195 msgstr "特殊文字ってすごいけど、ドットやクエスチョンマークにマッチさせたかったらどうすればいい?"
196
197 #: ../../../__w/calibre/calibre/manual/regexp.rst:58
198 msgid ""
199 "You can of course do that: Just put a backslash in front of any special "
200 "character and it is interpreted as the literal character, without any "
201 "special meaning. This pair of a backslash followed by a single character is "
202 "called an escape sequence, and the act of putting a backslash in front of a "
203 "special character is called escaping that character. An escape sequence is "
204 "interpreted as a single element. There are of course escape sequences that "
205 "do more than just escaping special characters, for example ``\"\\t\"`` means"
206 " a tabulator. We'll get to some of the escape sequences later. Oh, and by "
207 "the way, concerning those special characters: Consider any character we "
208 "discuss in this introduction as having some function to be special and thus "
209 "needing to be escaped if you want the literal character."
210 msgstr "もちろんできます。特殊文字の前にバックスラッシュをつければ、特別な意味のない文字リテラルとして解釈されます。特殊文字の前にバックスラッシュをつけた組み合わせのことを、エスケープシーケンスと呼び、特殊文字の前にバックスラッシュをつけることを文字をエスケープすると言います。エスケープシーケンスはひとつの要素と解釈されます。もちろんただ単に特殊文字をエスケープするだけでないエスケープシーケンスも存在します。たとえば ``\"\\t\"`` はタブ文字を表します。エスケープシーケンスについては、また後で説明します。ちなみに、この特殊文字についてですが、この入門書の中で何か機能があると紹介する文字はどれも特殊文字であり、したがって文字リテラルとしたいときにはエスケープする必要があると考えてください。"
211
212 #: ../../../__w/calibre/calibre/manual/regexp.rst:61
213 msgid "So, what are the most useful sets?"
214 msgstr "一番便利なセットは何ですか?"
215
216 #: ../../../__w/calibre/calibre/manual/regexp.rst:63
217 msgid ""
218 "Knew you'd ask. Some useful sets are ``[0-9]`` matching a single number, "
219 "``[a-z]`` matching a single lowercase letter, ``[A-Z]`` matching a single "
220 "uppercase letter, ``[a-zA-Z]`` matching a single letter and ``[a-zA-Z0-9]`` "
221 "matching a single letter or number. You can also use an escape sequence as "
222 "shorthand:"
223 msgstr "聞かれると思ってました。便利なセットといえば、1 桁の数字にマッチする ``[0-9]``、小文字 1 個にマッチする ``[a-z]``、大文字 1 個にマッチする ``[A-Z]``、アルファベット 1 文字にマッチする ``[a-zA-Z]``、そして英数字 1 文字にマッチする ``[a-zA-Z0-9]`` などがあります。略記法としてエスケープシーケンスを使用することもできます:"
224
225 #: ../../../__w/calibre/calibre/manual/regexp.rst:69
226 msgid "``\\d``"
227 msgstr "``\\d``"
228
229 #: ../../../__w/calibre/calibre/manual/regexp.rst:70
230 msgid "is equivalent to ``[0-9]``"
231 msgstr "``[0-9]`` と同等"
232
233 #: ../../../__w/calibre/calibre/manual/regexp.rst:72
234 msgid "``\\w``"
235 msgstr "``\\w``"
236
237 #: ../../../__w/calibre/calibre/manual/regexp.rst:73
238 msgid "is equivalent to ``[a-zA-Z0-9_]``"
239 msgstr "``[a-zA-Z0-9_]`` と同等"
240
241 #: ../../../__w/calibre/calibre/manual/regexp.rst:76
242 msgid "``\\s``"
243 msgstr "``\\s``"
244
245 #: ../../../__w/calibre/calibre/manual/regexp.rst:77
246 msgid "is equivalent to any whitespace"
247 msgstr "空白と同等"
248
249 #: ../../../__w/calibre/calibre/manual/regexp.rst:80
250 msgid ""
251 "\"Whitespace\" is a term for anything that won't be printed. These "
252 "characters include space, tabulator, line feed, form feed, carriage return, "
253 "non-breaking spaces, etc."
254 msgstr "\"空白\" とは印刷されないものすべてを表す用語です。空白にはスペース、タブ文字、改行、改ページ、行頭復帰、ノーブレークスペースなどが含まれます。"
255
256 #: ../../../__w/calibre/calibre/manual/regexp.rst:83
257 msgid ""
258 "The upper and lower case sets may match both upper and lowercase if the "
259 "setting to make searches case insensitive is enabled. Such settings are "
260 "found, for instance in Preferences->Searching in calibre itself and on the "
261 "Search panel in the calibre :guilabel:`E-book viewer` as well as the calibre"
262 " :guilabel:`Edit book` tool."
263 msgstr "検索で大文字と小文字を区別しない設定が有効になっていると、大文字と小文字のセットは大文字と小文字の両方にマッチします。そのような設定は、たとえば calibre 自身の 環境設定->検索 や calibre :guilabel:`電子書籍ビューア` の検索パネル、そして calibre :guilabel:`本の編集` ツールにあります。"
264
265 #: ../../../__w/calibre/calibre/manual/regexp.rst:89
266 msgid ""
267 "As a last note on sets, you can also define a set as any character *but* "
268 "those in the set. You do that by including the character ``\"^\"`` as the "
269 "*very first character in the set*. Thus, ``[^a]`` would match any character "
270 "excluding \"a\". That's called complementing the set. Those escape sequence "
271 "shorthands we saw earlier can also be complemented: ``\"\\D\"`` means any "
272 "non-number character, thus being equivalent to ``[^0-9]``. The other "
273 "shorthands can be complemented by, you guessed it, using the respective "
274 "uppercase letter instead of the lowercase one. So, going back to the example"
275 " ``<p[^>]*>`` from the previous section, now you can see that the character "
276 "set it's using tries to match any character except for a closing angle "
277 "bracket."
278 msgstr "セットに関する最後の注意点として、セットはある文字を *除く* すべての文字と定義することが可能です。そのためには、文字 ``\"^\"`` をセットの *一番最初の文字として* 指定します。したがって ``[^a]`` は a 以外のどの文字ともマッチします。これをセットの補完と呼びます。前述したエスケープシーケンスでの略記法にも補完できます。``\"\\D\"`` は数字以外のどの文字にもマッチし、``[^0-9]`` と同等です。その他の略記法も、ご想像のとおり、それぞれ小文字の代わりに大文字を使うと補完になります。では、前の章で例として挙げた ``<p[^>]*>`` に戻ってみると、ここで使われている文字セットは山カッコを除く文字すべてにマッチさせようとしていることがわかります。"
279
280 #: ../../../__w/calibre/calibre/manual/regexp.rst:94
281 msgid ""
282 "But if I had a few varying strings I wanted to match, things get "
283 "complicated?"
284 msgstr "マッチさせたい文字列がいろいろあると、複雑になりますか?"
285
286 #: ../../../__w/calibre/calibre/manual/regexp.rst:96
287 msgid ""
288 "Fear not, life still is good and easy. Consider this example: The book "
289 "you're converting has \"Title\" written on every odd page and \"Author\" "
290 "written on every even page. Looks great in print, right? But in e-books, "
291 "it's annoying. You can group whole expressions in normal parentheses, and "
292 "the character ``\"|\"`` will let you match *either* the expression to its "
293 "right *or* the one to its left. Combine those and you're done. Too fast for "
294 "you? Okay, first off, we group the expressions for odd and even pages, thus "
295 "getting ``(Title)(Author)`` as our two needed expressions. Now we make "
296 "things simpler by using the vertical bar (``\"|\"`` is called the vertical "
297 "bar character): If you use the expression ``(Title|Author)`` you'll either "
298 "get a match for \"Title\" (on the odd pages) or you'd match \"Author\" (on "
299 "the even pages). Well, wasn't that easy?"
300 msgstr "心配いりません。まだまだ人生は楽勝です。次の例を考えてみましょう: 変換しようとしている本に、奇数ページごとに \"タイトル\" が、偶数ページごとに \"著者名\" が書かれているとします。印刷では見栄えがしますよね? しかし電子書籍では邪魔なだけです。表現全体を普通のカッコで囲むとグループ化できます。そして文字 ``\"|\"`` を使うと右側の表現 *または* 左側の表現の *いずれか* にマッチします。これをつなげれば、おしまいです。速すぎましたか? いいでしょう、まず最初に、奇数ページ用と偶数ページ用に表現をグループ化します。そうすると必要となる 2 つの表現として ``(タイトル)(著者名)`` が得られます。さて、これを縦線 (``\"|\"`` は縦線と呼ばれます) を使って簡単にします。正規表現 ``(タイトル|著者名)`` を使うと、\"タイトル\" (奇数ページ) または \"著者名\" (偶数ページ) のいずれかにマッチするようになります。ほら、簡単でしょう?"
301
302 #: ../../../__w/calibre/calibre/manual/regexp.rst:98
303 msgid ""
304 "You can, of course, use the vertical bar without using grouping parentheses,"
305 " as well. Remember when I said that quantifiers repeat the element preceding"
306 " them? Well, the vertical bar works a little differently: The expression "
307 "\"Title|Author\" will also match either the string \"Title\" or the string "
308 "\"Author\", just as the above example using grouping. *The vertical bar "
309 "selects between the entire expression preceding and following it*. So, if "
310 "you wanted to match the strings \"Calibre\" and \"calibre\" and wanted to "
311 "select only between the upper- and lowercase \"c\", you'd have to use the "
312 "expression ``(c|C)alibre``, where the grouping ensures that only the \"c\" "
313 "will be selected. If you were to use ``c|Calibre``, you'd get a match on the"
314 " string \"c\" or on the string \"Calibre\", which isn't what we wanted. In "
315 "short: If in doubt, use grouping together with the vertical bar."
316 msgstr "もちろん縦線をグループ化するカッコなしで使用することも可能です。ところで量指定子はその前の要素を繰り返すと説明したときのことを覚えていますか? 縦線の作用は少し異なります。正規表現 \"タイトル|著者名\" は、上でグループを使った例とまったく同じように、文字列 \"タイトル\" または文字列 \"著者名\" のいずれかに一致します。*縦線は、その前の表現全部と、その後ろの表現全部のうちから選択します*。したがって、もし文字列 \"Calibre\" と \"calibre\" にマッチさせたくて、大文字と小文字の 違いは\"c\" だけにしたい時は、使用する正規表現は ``(c|C)alibre`` としなくてはなりません。こうすると \"c\" だけが選択されることが保証されます。もし ``c|Calibre`` とすると、文字列 \"c\" または文字列 \"Calibre\" にマッチするため、望んだ結果となりません。要するに、よくわからないときには縦線を使う場合にはグループ化しましょう。"
317
318 #: ../../../__w/calibre/calibre/manual/regexp.rst:101
319 msgid "You missed..."
320 msgstr "見落としがあります..."
321
322 #: ../../../__w/calibre/calibre/manual/regexp.rst:103
323 msgid ""
324 "... wait just a minute, there's one last, really neat thing you can do with "
325 "groups. If you have a group that you previously matched, you can use "
326 "references to that group later in the expression: Groups are numbered "
327 "starting with 1, and you reference them by escaping the number of the group "
328 "you want to reference, thus, the fifth group would be referenced as ``\\5``."
329 " So, if you searched for ``([^ ]+) \\1`` in the string \"Test Test\", you'd "
330 "match the whole string!"
331 msgstr "…ちょっと待ってください。最後にひとつ、グループ化でできるすばらしいことがあります。前にマッチしたグループがあれば、そのグループをその正規表現の中で後で利用できるのです。グループには 1 から始まる番号がつけられ、参照したいグループの番号をエスケープすると参照できます。ですから 5 番目のグループを参照するには ``\\5`` とします。したがって文字列 \"Test Test\" に対して ``([^ ]+) \\1`` で検索すると、文字列全体にマッチします。"
332
333 #: ../../../__w/calibre/calibre/manual/regexp.rst:107
334 msgid ""
335 "In the beginning, you said there was a way to make a regular expression case"
336 " insensitive?"
337 msgstr "最初の方で、正規表現に大文字と小文字を区別させない方法があると言いましたよね?"
338
339 #: ../../../__w/calibre/calibre/manual/regexp.rst:109
340 msgid ""
341 "Yes, I did, thanks for paying attention and reminding me. You can tell "
342 "calibre how you want certain things handled by using something called flags."
343 " You include flags in your expression by using the special construct "
344 "``(?flags go here)`` where, obviously, you'd replace \"flags go here\" with "
345 "the specific flags you want. For ignoring case, the flag is ``i``, thus you "
346 "include ``(?i)`` in your expression. Thus, ``(?i)test`` would match "
347 "\"Test\", \"tEst\", \"TEst\" and any case variation you could think of."
348 msgstr "はい、そのとおりです。傾聴とご指摘をありがとうございます。フラグと呼ばれるものを使用すると、calibre にある物事をどのように処理して欲しいのか伝えることができます。フラグを正規表現に含めるには、特殊な構文 ``(?指定フラグ)`` を使用し、「指定フラグ」 の部分を指定したいフラグで置き換えます。大文字と小文字を区別しないようにするフラグは ``i`` なので、正規表現の中に ``(?i)`` を含めます。ですから `(?i)test`` は \"Test\", \"tEst\", \"TEst\" など思いつく限りすべてのバリエーションとマッチします。"
349
350 #: ../../../__w/calibre/calibre/manual/regexp.rst:111
351 msgid ""
352 "Another useful flag lets the dot match any character at all, *including* the"
353 " newline, the flag ``s``. If you want to use multiple flags in an "
354 "expression, just put them in the same statement: ``(?is)`` would ignore case"
355 " and make the dot match all. It doesn't matter which flag you state first, "
356 "``(?si)`` would be equivalent to the above."
357 msgstr "もうひとつの便利なフラグ ``s`` を使用すると、ドットを改行を *含めて* すべての文字にマッチさせることができます。正規表現の中で使用したいフラグが複数ある場合には、同じ記述の中に含めてかまいません。``(?is)`` とすると大文字と小文字を区別せず、ドットがすべての文字にマッチします。どちらのフラグを先に記述しても同じです。``(?si)`` は上のものと同等です。"
358
359 #: ../../../__w/calibre/calibre/manual/regexp.rst:114
360 msgid ""
361 "I think I'm beginning to understand these regular expressions now... how do "
362 "I use them in calibre?"
363 msgstr "だんだん正規表現がわかってきた気がします。calibre ではどう使いますか?"
364
365 #: ../../../__w/calibre/calibre/manual/regexp.rst:117
366 msgid "Conversions"
367 msgstr "変換"
368
369 #: ../../../__w/calibre/calibre/manual/regexp.rst:119
370 msgid ""
371 "Let's begin with the conversion settings, which is really neat. In the "
372 ":guilabel:`Search & replace` part, you can input a regexp (short for regular"
373 " expression) that describes the string that will be replaced during the "
374 "conversion. The neat part is the wizard. Click on the wizard staff and you "
375 "get a preview of what calibre \"sees\" during the conversion process. Scroll"
376 " down to the string you want to remove, select and copy it, paste it into "
377 "the regexp field on top of the window. If there are variable parts, like "
378 "page numbers or so, use sets and quantifiers to cover those, and while "
379 "you're at it, remember to escape special characters, if there are some. Hit "
380 "the button labeled :guilabel:`Test` and calibre highlights the parts it "
381 "would replace were you to use the regexp. Once you're satisfied, hit OK and "
382 "convert. Be careful if your conversion source has tags like this example::"
383 msgstr "変換の設定から始めましょう。非常によくできています。:guilabel:`検索と置換` の部分に、変換中に置き換えたい文字列を記述する regexp (正規表現の略称) を入力できます。よくできている部分はウィザードです。ウィザードの杖ボタンをクリックすると、変換処理中に calibre に \"見える\" もののプレビューが表示されます。削除したい文字列のところまで下へスクロールして、選択してコピーし、ウィンドウの上部にある正規表現フィールドに貼り付けます。もしページ番号のような可変な部分があればセットと量指定子を使用して保護し、ついでに特殊文字があれば忘れずにエスケープします。:guilabel:`テスト` とラベルのついたボタンを押すと、calibre は正規表現で置換する部分をハイライト表示します。満足できたら OK を押して変換します。もし変換ソースに次の例のようなタグがある場合には、注意してください::"
384
385 #: ../../../__w/calibre/calibre/manual/regexp.rst:129
386 msgid ""
387 "(shamelessly ripped out of `this thread "
388 "<https://www.mobileread.com/forums/showthread.php?t=75594\">`_). You'd have "
389 "to remove some of the tags as well. In this example, I'd recommend beginning"
390 " with the tag ``<b class=\"calibre2\">``, now you have to end with the "
391 "corresponding closing tag (opening tags are ``<tag>``, closing tags are "
392 "``</tag>``), which is simply the next ``</b>`` in this case. (Refer to a "
393 "good HTML manual or ask in the forum if you are unclear on this point). The "
394 "opening tag can be described using ``<b.*?>``, the closing tag using "
395 "``</b>``, thus we could remove everything between those tags using "
396 "``<b.*?>.*?</b>``. But using this expression would be a bad idea, because it"
397 " removes everything enclosed by <b>- tags (which, by the way, render the "
398 "enclosed text in bold print), and it's a fair bet that we'll remove portions"
399 " of the book in this way. Instead, include the beginning of the enclosed "
400 "string as well, making the regular expression "
401 "``<b.*?>\\s*Generated\\s+by\\s+ABC\\s+Amber\\s+LIT.*?</b>`` The ``\\s`` with"
402 " quantifiers are included here instead of explicitly using the spaces as "
403 "seen in the string to catch any variations of the string that might occur. "
404 "Remember to check what calibre will remove to make sure you don't remove any"
405 " portions you want to keep if you test a new expression. If you only check "
406 "one occurrence, you might miss a mismatch somewhere else in the text. Also "
407 "note that should you accidentally remove more or fewer tags than you "
408 "actually wanted to, calibre tries to repair the damaged code after doing the"
409 " removal."
410 msgstr "(図々しくも `このスレッド <https://www.mobileread.com/forums/showthread.php?t=75594\">`_ からパクってきました) 一部のタグも削除する必要があります。この例では、タグ ``<b class=\"calibre2\">`` で開始することをお勧めします。次に、対応する終了タグ (開始タグ ``<tag>`` で、終了タグは ``</tag>``) で終了する必要があります。このケースでは単純に次の ``</b>`` です。(これに関して不明な点があれば、優れた HTML マニュアルを参照するか、フォーラムで質問してください。) 開始タグは ``<b.*?>`` と表すことができ、終了タグは ``</b>`` で表せます。したがって ``<b.*?>.*?</b>`` を使用すると、このタグの間にあるものすべてを削除できます。しかしこの正規表現の使用はお勧めできません。なぜなら <b> タグで囲まれたもの (これは囲まれたテキストを太字にします) すべてを削除してしまうため、まず間違いなく本の一部が消えてしまうでしょう。代わりに囲まれた文字列の先頭部分も含めて、正規表現を ``<b.*?>\\s*Generated\\s+by\\s+ABC\\s+Amber\\s+LIT.*?</b>`` とします。見えているとおりにスペースを含める代わりに、どのような文字列の組み合わせになっていてもキャッチできるよう量指定子つきの ``\\s`` が使われています。新しい正規表現をテストするときには、削除したくないものが削除されることのないよう、calibre が何を削除するかを忘れずに確認してください。1 回の出現しか確認しないと、テキストの他の場所での食い違いを見逃す可能性があります。さらに、実際に望んだよりも多いまたは少ないタグを削除してしまうことがありますが、calibre は削除を行った後に破損したコードの修復を試みます。"
411
412 #: ../../../__w/calibre/calibre/manual/regexp.rst:132
413 msgid "Adding books"
414 msgstr "本の追加"
415
416 #: ../../../__w/calibre/calibre/manual/regexp.rst:134
417 msgid ""
418 "Another thing you can use regular expressions for is to extract metadata "
419 "from filenames. You can find this feature in the \"Adding books\" part of "
420 "the settings. There's a special feature here: You can use field names for "
421 "metadata fields, for example ``(?P<title>)`` would indicate that calibre "
422 "uses this part of the string as book title. The allowed field names are "
423 "listed in the windows, together with another nice test field. An example: "
424 "Say you want to import a whole bunch of files named like ``Classical Texts: "
425 "The Divine Comedy by Dante Alighieri.mobi``. (Obviously, this is already in "
426 "your library, since we all love classical Italian poetry) or ``Science "
427 "Fiction epics: The Foundation Trilogy by Isaac Asimov.epub``. This is "
428 "obviously a naming scheme that calibre won't extract any meaningful data out"
429 " of - its standard expression for extracting metadata is ``(?P<title>.+) - "
430 "(?P<author>[^_]+)``. A regular expression that works here would be "
431 "``[a-zA-Z]+: (?P<title>.+) by (?P<author>.+)``. Please note that, inside the"
432 " group for the metadata field, you need to use expressions to describe what "
433 "the field actually matches. And also note that, when using the test field "
434 "calibre provides, you need to add the file extension to your testing "
435 "filename, otherwise you won't get any matches at all, despite using a "
436 "working expression."
437 msgstr "正規表現を使う別の用途は、ファイル名からメタデータを抽出することです。この機能は環境設定の *本の追加* タブにあります。ここには特別な機能があります: メタデータフィールドにフィールド名を使用できるのです。例えば、 ``(?P<title>)`` と指定すると、calibreはこの文字列の部分を本のタイトルとして扱います。使用可能なフィールド名は、便利なテストフィールドと共にウィンドウに表示されます。例えば、 ``Classical Texts: The Divine Comedy by Dante Alighieri.mobi`` といった名前のファイルを大量にインポートするとします。(もちろん、イタリア古典詩が好きな人は皆そうでしょうから、これは既にライブラリに入っています。)あるいは ``Science Fiction epics: The Foundation Trilogy by Isaac Asimov.epub`` といった名前のファイルをインポートするとします。メタデータ抽出の標準表現は ``(?P2.+) - (?P3[^_]+)`` ですので、このままでは明らかに、calibreが意味のあるデータを抽出できません。そのため、ここで有効な正規表現は ``[a-zA-Z]+: (?P<title>.+) by (?P<author>.+)`` となります。メタデータフィールドのグループ内では、フィールドが実際に何に一致するかを表す正規表現を使用する必要があることに注意してください。また、Calibreが提供するテストフィールドを使用する場合は、テストファイル名にファイル拡張子を追加する必要があります。そうしないと、有効な正規表現を使用しても、一致する結果が全く得られません。"
438
439 #: ../../../__w/calibre/calibre/manual/regexp.rst:138
440 msgid "Bulk editing metadata"
441 msgstr "書誌を一括編集"
442
443 #: ../../../__w/calibre/calibre/manual/regexp.rst:140
444 msgid ""
445 "The last part is regular expression :guilabel:`Search and replace` in "
446 "metadata fields. You can access this by selecting multiple books in the "
447 "library and using bulk metadata edit. Be very careful when using this last "
448 "feature, as it can do **Very Bad Things** to your library! Double-check that"
449 " your expressions do what you want them to using the test fields, and only "
450 "mark the books you really want to change! In the regular expression search "
451 "mode, you can search in one field, replace the text with something and even "
452 "write the result into another field. A practical example: Say your library "
453 "contained the books of Frank Herbert's Dune series, named after the fashion "
454 "``Dune 1 - Dune``, ``Dune 2 - Dune Messiah`` and so on. Now you want to get "
455 "``Dune`` into the series field. You can do that by searching for ``(.*?) "
456 "\\d+ - .*`` in the title field and replacing it with ``\\1`` in the series "
457 "field. See what I did there? That's a reference to the first group you're "
458 "replacing the series field with. Now that you have the series all set, you "
459 "only need to do another search for ``.*? -`` in the title field and replace "
460 "it with ``\"\"`` (an empty string), again in the title field, and your "
461 "metadata is all neat and tidy. Isn't that great? By the way, instead of "
462 "replacing the entire field, you can also append or prepend to the field, so,"
463 " if you *wanted* the book title to be prepended with series info, you could "
464 "do that as well. As you by now have undoubtedly noticed, there's a checkbox "
465 "labeled :guilabel:`Case sensitive`, so you won't have to use flags to select"
466 " behaviour here."
467 msgstr "最後の部分は、メタデータフィールドでの正規表現による :guilabel:`検索と置換` です。ライブラリで複数の本を選択し、メタデータの一括編集を使用することで、この機能にアクセスできます。この機能は、ライブラリに **非常に悪い影響** を与える可能性があるため、使用する際は十分に注意してください。テストフィールドを使用して、式が意図したとおりに機能することを再確認し、本当に変更したい本のみにマークを付けてください。正規表現検索モードでは、1つのフィールドで検索し、テキストを何かに置き換え、結果を別のフィールドに書き込むことができます。実用的な例: ライブラリに、Frank Herbert の Dune シリーズの書籍があり、シリーズの流儀で「Dune 1 - Dune」、「Dune 2 - Dune Messiah」などと名付けられているとします。ここで、シリーズフィールドに「Dune」を挿入します。タイトルフィールドで ``(.*?) \\d+ - .*`` を検索し、シリーズフィールドで ``\\1`` に置き換えることで実行できます。何をしたかお分かりですか?これは、シリーズフィールドを置き換える最初のグループへの参照です。これでシリーズの設定がすべて完了したので、タイトルフィールドでもう一度 ``.*? -`` を検索し、 ``\"\"`` (空の文字列)に置き換えるだけで、メタデータがすべて整頓されます。素晴らしいと思いませんか?ちなみに、フィールド全体を置き換える代わりに、フィールドの先頭または末尾に追加することもできます。つまり、本のタイトルの先頭にシリーズ情報を *追加したい* 場合は、それも可能です。もうお気づきだと思いますが、 :guilabel:`大文字と小文字を区別する` というチェックボックスがあるので、ここでフラグを使って動作を選択する必要はありません。"
468
469 #: ../../../__w/calibre/calibre/manual/regexp.rst:142
470 msgid ""
471 "Well, that just about concludes the very short introduction to regular "
472 "expressions. Hopefully I'll have shown you enough to at least get you "
473 "started and to enable you to continue learning by yourself- a good starting "
474 "point would be the `Python documentation for regexps "
475 "<https://docs.python.org/library/re.html>`_."
476 msgstr "さて、これで正規表現のごく簡単な紹介は終わりです。願わくば紹介した内容が、少なくとも自分で学び続けることができるに足るものでありますように。 `Python documentation for regexps <https://docs.python.org/library/re.html>`_ から始めるとよいでしょう。"
477
478 #: ../../../__w/calibre/calibre/manual/regexp.rst:144
479 msgid ""
480 "One last word of warning, though: Regexps are powerful, but also really easy"
481 " to get wrong. calibre provides really great testing possibilities to see if"
482 " your expressions behave as you expect them to. Use them. Try not to shoot "
483 "yourself in the foot. (God, I love that expression...). But should you, "
484 "despite the warning, injure your foot (or any other body parts), try to "
485 "learn from it."
486 msgstr "ただし最後にひとつだけ警告しておきます。正規表現は強力ですが、同時にまた非常に簡単に間違いを引き起こすものでもあります。calibre は正規表現が期待どおりに動くかどうか確認するために、すばらしいテストツールを用意しています。それを利用してください。自分の足を撃ち抜くような真似はしないでください。(この表現、素敵でしょう…) けれどももし、警告があったにもかかわらず足 (または身体のどこか他の部分) にケガを負ってしまった場合には、そこから学ぶよう努めてください。"
487
488 #: ../../../__w/calibre/calibre/manual/regexp.rst:148
489 msgid "Quick reference"
490 msgstr "クイックリファレンス"
491
492 #: ../../../__w/calibre/calibre/manual/regexp.rst:156
493 msgid "Credits"
494 msgstr "謝辞"
495
496 #: ../../../__w/calibre/calibre/manual/regexp.rst:158
497 msgid "Thanks for helping with tips, corrections and such:"
498 msgstr "記述や誤字修正などの助力に感謝します。"
499
500 #: ../../../__w/calibre/calibre/manual/regexp.rst:160
501 msgid "ldolse"
502 msgstr "ldolse"
503
504 #: ../../../__w/calibre/calibre/manual/regexp.rst:161
505 msgid "kovidgoyal"
506 msgstr "kovidgoyal"
507
508 #: ../../../__w/calibre/calibre/manual/regexp.rst:162
509 msgid "chaley"
510 msgstr "chaley"
511
512 #: ../../../__w/calibre/calibre/manual/regexp.rst:163
513 msgid "dwanthny"
514 msgstr "dwanthny"
515
516 #: ../../../__w/calibre/calibre/manual/regexp.rst:164
517 msgid "kacir"
518 msgstr "kacir"
519
520 #: ../../../__w/calibre/calibre/manual/regexp.rst:165
521 msgid "Starson17"
522 msgstr "Starson17"
523
524 #: ../../../__w/calibre/calibre/manual/regexp.rst:166
525 msgid "Orpheu"
526 msgstr "Orpheu"
527
528 #: ../../../__w/calibre/calibre/manual/regexp.rst:168
529 msgid ""
530 "For more about regexps see `The Python User Manual "
531 "<https://docs.python.org/library/re.html>`_. The actual regular expression "
532 "library used by calibre is: `regex <https://bitbucket.org/mrabarnett/mrab-"
533 "regex/src/hg/>`_ which supports several useful enhancements over the Python "
534 "standard library one."
535 msgstr "正規表現についてさらに詳しく学ぶには、 `The Python User Manual <https://docs.python.org/library/re.html>`_ を参照してください。calibre で使用している正規表現ライブラリは `regex <https://bitbucket.org/mrabarnett/mrab-regex/src/hg/>`_ です。これは Python 標準のライブラリに比較するといくつか便利な拡張機能を備えています。"