I just opened a spreadsheet with addresses to try what you guys are talking
about. Of course there are a lot of numbers in it, most of them are Swedish
"zip codes" (we don't call them that, but that doesn't matter) which always
are three digits followed by a space and then two more digits, like "445
37". There are also streed addresses with numbers that can be 1 or more
digits etc.

I tried the following:

[:digit:] -> Nothing was found

[:digit:]? -> The first thing found was
a cell containing "106 27". Maybe it just stopped at the "1", but
when searching again it stops at the next cell with a number in it, not at
the "0" in the same cell. Maybe this works more as
expected when using it with Writer.

[:digit:]+ -> Seems to find the same cells as [:digit:]? did.

[:digit:]{3} -> Only cells with exactly three
digits in a row are found, such as "106 27" and "Norrholmsv. 175".


Since I almost never use Writer, I opened a new document in which I intered
the following:
32165498352168 654 32 68 51 68 3 2 5 86 4598 76 5468 465 8 1

Here are the results:
[:digit:] -> Nothing was found

[:digit:]? -> The first thing found was "3", next was "2" etc. Just as
expected.

[:digit:]+ -> First thing found
was "32165498352168", next was "654", which also was expected.

[:digit:]{3} -> First thing found was "321", then "654", "983",
"521", "654", "459". So it also finds parts of
numbers longer than three digits. So why doesn't it, after finding
"321" find "216" rather than
"654"?

Johnny Andersson

2007/2/21, ben <[EMAIL PROTECTED]>:


----- Original Message -----
>>> I've found in the help box of regular expressions the opportunity of
>>> searching for digits by means of [:digit:] expression.
>>>
>>> But it doesn't seem to work.

<snip>

> After seeing Joe's post:
> Search for:
> [:digit:]? will find any _single_ digit, example: 1
> [:digit:+? will find and combination of digits ex: 10,100, 1000 etc
--------------------------

Why +? , why not simply  +  ? Here is how I see this.

A specification like [:xxx:] is used when searching for a _string_ of
objects of a certain type.

The part that replaces xxx specifies the _type_ of object one is looking
for
(e.g., replacing xxx by  digit  specifies a decimal digit). By itself, a
specification like[:xxx:] is incomplete; one must also state the _length
of
string_ (and that can be done with ? , + , or {k}). Thus
search for  [:digit:]?  finds the next decimal digit (string of digits, of
length 1)
search for  [:digit:]+  finds the next string of decimal digits (of any
length)
search for  [:digit:]{2}  finds the next string of 2 decimal digits
etc

Likewise for [:space:]?, [:space:]+, [:space:]{2} and other such searches.

Vous ĂȘtes d'accord?
C'est simple, n'est-ce pas?

Ben


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to