[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: [LI] search and replace using Regular Expressions



On Wed, Jan 05, 2000 at 09:56:11AM -0700, Sitaram Chamarty wrote:

> > :%s/\(^[a-z<>A-Z0-9/:."'=~()?\-&%# ]*\)/\1<\/a>/gc
> > it fails
> 
> First things first: you dont have a closing \) there.

Sorry - my mistake.  You do have one - I missed it.

Most likely cause for failure is the fact that the hyphen is in
the middle.  In a character class, put the hyphen at the beginning
or the end.  There may be other problems depending on what flavour
of vi you are using and whether "magic" is on or not, but, without
a thorough check, that looks likely.

> Secondly, your character class has almost all printable chars
> there.  If that's what you intended, use .* instead of
> [allthatstuff]*.
> 
> Lastly, to append a fixed string to any lines in vi:
>     :%s/$/<\/a>/g
> No need to bother with what the line actually has if you don't
> really care.
> 
> Hope this helps.  Any more regex problems feel free to ask.
> --------------------------------------------------------------------
> The Linux India Mailing List Archives are now available.  Please search
> the archive at http://lists.linux-india.org/ before posting your question
> to avoid repetition and save bandwidth.
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.