[clug] awk or Perl regex question

Kim Holburn kim at holburn.net
Sat Jul 20 10:25:06 UTC 2019


Hi Steve \,

Would you be able to include a sample of name data, not necessarily real but realistic and the kind of output you want to get?

Kim

> On 2019/Jul/20, at 6:08 pm, steve jenkin via linux <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 http://members.tip.net.au/~sjenkin
> 
> 
> -- 
> linux mailing list
> 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  aim://kimholburn
skype://kholburn - PGP Public Key on request 





More information about the linux mailing list