weklica
asked on
Regular Expressions
I have a simple request:
I have something like this:
Lastname^Firstname^^^
sometimes
Lastname^Firstname^MI^^
What I need is a regular expression like ([^.]*).[^.]*.[^.]* that would show me just the Lastname as a result, then just the first name, then just the middle initial.
The example I pasted will do it if it is like Lastname.Firstname.MI, but I do not have any idea how to work with carrot symbols since those are already being used in the expression.
I have something like this:
Lastname^Firstname^^^
sometimes
Lastname^Firstname^MI^^
What I need is a regular expression like ([^.]*).[^.]*.[^.]* that would show me just the Lastname as a result, then just the first name, then just the middle initial.
The example I pasted will do it if it is like Lastname.Firstname.MI, but I do not have any idea how to work with carrot symbols since those are already being used in the expression.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
([^^]*)
should be is sufficient for just Lastname
([^^]*)\^([^^]*)\^([^^]*)
should get Last, then First, then middle
should be is sufficient for just Lastname
([^^]*)\^([^^]*)\^([^^]*)
should get Last, then First, then middle
Yup, my mistake, ozo's right, you gotta escape the carat outside the matching sets too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Much!
ASKER
([^^]*)^[^^]*^[^^]*