[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A Regular Expression Question



You might check the matches with

$ grep -nH --color=auto '<regex>' <scripts>

and then reuse the regex in sed.
--hh


"Martin G. McCormick" <martin@server1.shellworld.net> wrote (Tue, 10
Jun 2014 14:01:20 -0500):
> I am trying to remove the & or ampersand sign from some perl
> code I wrote as it is not necessary. I have no trouble finding
> all the instances because they consist of an ampersand
> immediately followed by a letter so &[a-z] describes the case
> perfectly. 
> The replacement pattern should actually be the same as the
> search pattern except that it is missing the & or ampersand.
> 
> 	The scripts have loads of logical &'s and &&'s in them
> so the regular expression seems to be the safest way to globally
> replace &everything with just everything. In this case, a global
> pattern that returned the search pattern missing it's first
> letter would even work.
> 
> Thank you.
> 
> Martin McCormick
> 
> 


Reply to: