[clug] awk or Perl regex question

Kim Holburn Kim at holburn.net
Sat Jul 20 21:23:42 UTC 2019


Does this do what you want?

 perl -p -e 's/\b[A-Z][a-z]+\b//g;s#^[/\s]*##;' < names.txt

I sent this but it never seemed to have arrived.  Perhaps filtered by AV?

> On 2019/Jul/20, at 6:08 pm, steve jenkin via linux <linux at lists.samba.org <mailto:linux at lists.samba.org>> wrote:
> 
> In awk, I’m trying to remove First Names from Full Name strings.
> There might be multiple first names and alternative separated by a ‘/‘
> 
> Surnames as UPPERCASE and happen at the end of the string [and may contain single quote (O’SHEA) or  a blank (DE SMETS).
> 
> Currently I’ve got a working version doing two different subs, the first is unanchored, the second is anchored to the start of the string (^)
> 
> 	sub(/Mc[A-Z][a-z]* /, "", A[1]); 
> 	sub(/^([A-Z][a-z\047]*[ /])+/, "", A[1]);
> 
> I’ve tried this regex, unachored and not, with ‘?’ for 0 or 1 repeats of the group or ‘*’ for 0 or more repeats.
> 
> 	(Mc)?([A-Z][a-z\047]*[ /])+
> 
> Any suggestions for other things to try?
> 
> --
> Steve Jenkin, IT Systems and Design 
> 0412 786 915 (+61 412 786 915)
> PO Box 38, Kippax ACT 2615, AUSTRALIA
> 
> mailto:sjenkin at canb.auug.org.au <mailto:sjenkin at canb.auug.org.au> http://members.tip.net.au/~sjenkin <http://members.tip.net.au/~sjenkin>
> 
> 
> -- 
> linux mailing list
> linux at lists.samba.org <mailto:linux at lists.samba.org>
> https://lists.samba.org/mailman/listinfo/linux

-- 
Kim Holburn
IT Network & Security Consultant
T: +61 2 61402408  M: +61 404072753
mailto:kim at holburn.net <mailto:kim at holburn.net>  aim://kimholburn <aim://kimholburn>
skype://kholburn <skype://kholburn> - PGP Public Key on request 





More information about the linux mailing list