At 19:51 21/08/2009 +0200, Jonathan Kaye wrote:
Here is my second question, Pradeep, since you
know regular expressions quite well.
Sorry, I'm not Pradeep; will I do?
I want to match a string from the start of the
record to the first full-stop (if any) in the
record. That part is easy: ^.*\. gives me what I want.
Actually, it's not quite as easy as
that. Regular expressions match as much as
possible: they are sometime described as
"greedy". So your expression matches everything
up to the *last* full stop in a paragraph, in fact. You need something like
^[^\.]*\.
instead. The part enclosed in square brackets
matches anything that is not a full stop.
Now the hard part: in the replace field, how can
I refer to the material matched by .* ?
By putting it in parentheses. You can refer to
strings that are matched by parenthesised expressions using $1, $2, and so on.
I would like to surround the matched material
with « at the beginning and » at the end. So,
for example, if a have a record like this:
delete.me, I would like to replace it with this: «delete»me Is this possible?
Yes. Search for
^([^\.]*)\.
and replace with
«$1»
I trust this helps.
Brian Barker
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]