Thursday, 8 August 2013

regex exp how to match multiple optional cases

regex exp how to match multiple optional cases

I have a string like this format {Name,Address,(PhoneNumber1)*};
(PhoneNumber1)* means PhoneNumber can appear 0 to infinite times.
I want to get texts of Name, Address, and all the PhoneNumber if they
present in the text.
for example:
{Name1,Addr1} will return Name1 as group 1, Addr1 as group 2
{Name1,Addr1,Phone1,Phone2} will return Name1 as group 1, Addr1 as group2,
Phone1 as group3, Phone2 as group4, etc.

No comments:

Post a Comment