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

Re: [LI] search and replace using Regular Expressions



Anand Raman forced the electrons to say:
> Hi friends
> To the end of each of these lines i want to append a </a> tag .. 
> 
> I tried doing this in vi editor and the following regular expression matches
> the whole line 
> /^[a-z<>A-Z0-9/:."'=~()?\-&%# ]*

Phew... What a regex...

The following regex also matches an entire line...

^.*$
> 
> However when i try to append the contents using the following 
> :%s/\(^[a-z<>A-Z0-9/:."'=~()?\-&%# ]*\)/\1<\/a>/gc
> it fails

I can't even look into this and see which is the offending character -
probably the backslash in there...

The way to achieve what you want is:

%s/$/<\/a>/gc

Binand

-- 
#include <stdio.h>                                   | Binand Raj S.
char *p = "#include <stdio.h>%cchar *p = %c%s%c;     | This is a self-
int main(){printf(p,10,34,p,34,10);return 0;}%c";    | printing program.
int main(){printf(p,10,34,p,34,10);return 0;}        | Try it!!
--------------------------------------------------------------------
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.