----- Original Message ----- From: "Richard Detwiler" <[EMAIL PROTECTED]>
I had some trouble getting certain regular expressions to work. Here's an example, taken from Help:
[:space:]   Represents a white space character such as space.
When I try this, I get the message that the search key was not found, even though there are lots of spaces in the document I was searching.

Hello Richard,

A while ago -- in early February, I think -- there was some activity in this mailing list regarding searches that involve specs such as [:xxx:], e.g. [:digit:] or [:space:]. As was then pointed out, useful information about regular expressions can be found in an article by Garry Knight:
http://homepage.ntlworld.com/garryknight/linux/ooregexp.html
My contribution to that discussion was along the lines of what is stated below. I think you will find that it takes care of your problem.

Ben Winter

- - - - -

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. Apparently [aBc] (without colons) states specific, concrete objects to be matched, whereas [:xxx:] (with colons) refers to an abstract type. To get a searchable object, you need to add something to [:xxx:] to make it concrete; e.g., state a length-specification to move from the abstraction _digits_ to something concrete like 'string of 3 digits'.

However, by my interpretation, a[:digit:]b should not yield any hits - but it does.




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

Reply via email to