Two observations about your search pattern \d.\d.\d. First, it
doesn't have any quantifiers. Second, . matches any character,
not just a literal '.'. Your pattern matches a single numeric
digit followed by any single character, followed by a single
digit, followed by any single character, followed by a single
digit. For example, it would match the string '1#2M3', which is
clearly not like your intended target strings. To match patterns
as in your example, you'd use something more like:
\(\d{2}\.\d{2}\.\d{3}\)
Which works like so:
\( matches an open parenthesis
\d{2} matches exactly two numeric digits
\. matches a single literal .
\d{3} matches exactly three digits
\) matches a close parenthesis
It might also be written something like:
\((?:\d{2}\.){2}\d{3}\)
If the number of digits in each part of the pattern might vary,
you would want to use the + quantifier instead of the more
specific {2} and {3}:
\(\d+\.\d+\.\d+\)
>In a nutshell, HELP
In a nutshell, the Searching with Grep chapter in the TW manual
is an excellent primer on regular expressions.
--
Christopher Bort
<top...@thehundredacre.net>
\d finds only one digit and an unescaped period finds any character.
Your task looks very easy, you just have to escape the points and the
parentheses. Is
\(\d+\.\d+\.\d+\)
what you want?
Roy McCoy
UEA, Rotterdam NL
> This worked GREAT. Thanks again. I will reread the TW manual, but I
> admit it didn't make much sense to me.
http://mac4translators.blogspot.com/2011/04/introduction-to-regular-expressions.html
That should be simple enough to get you started. But the manual is really well written and easy to read.
Jean-Christophe Helary
----------------------------------------
fun: http://mac4translators.blogspot.com
work: http://www.doublet.jp (ja/en > fr)
tweets: http://twitter.com/brandelune
>This worked GREAT. Thanks again. I will reread the TW manual, but I
>admit it didn't make much sense to me.
Regular expressions is one of those topics that tends to be
fairly opaque when you first encounter them, until you have some
'Aha!' moment and then they all of a sudden make perfect sense.
Read the manual slowly and deliberately, starting with the
basics and don't move to the 'advanced' sections until you're
understanding the basics. As you read, you can have TW running
with some (any) text document and the Find dialog open. Then, as
you're reading, you can easily try out simple patterns to see
how they work. When you're writing more complex real-world
patterns, it's sometimes helpful to build them one simple part
at a time, testing as you go by performing finds on your actual
target text until you have a pattern that fully matches the text
you're looking for. Once you've learned regular expressions as
TW implements them, using the primer in the TW manual, you can
move on to many other sources, such as the O'Reilly book
'Mastering Regular Expressions,' to learn about how they're
implemented in other environments. If you work with text a lot,
regex is well worth the effort to learn; once you get it, you'll
wonder how you ever got by without it.
--
Christopher Bort
<top...@thehundredacre.net>