Thanks for the quick response, Flo. I actually needed an
expression
that handled an arbitrary number of given names, although my
example
just contained two. I was able to do it with
/^(.*?) ([^ ]+)(?: +(?:Sr|Jr).?)?$/i
This list is a great idea. There's no one here at work
that
understands regex's better than me so when I need help it's
nice to
have a place to go.
On Jun 26, 1:47 pm, Flo <sensor... gmail.com> wrote:
> I would use this regex
>
> ^s*(w+s+w+)s+(w+)
>
> $1 will contain the first two words on the line
> $2 will contain the third word on the line
>
> Leading and trailing white spaces are allowed
>
> If it is important that there are no further words
except an optional
> Jr. or Sr. do this:
>
> ^s*(w+s+w+)s+(w+)s*(s[JS]r.s*)?$
>
> Admittedly, I haven't tested the two regexes
>
> Greetings
>
> Flo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|