Parse Phone Number into component parts

后端 未结 6 1250
太阳男子
太阳男子 2020-12-31 11:27

I need a well tested Regular Expression (.net style preferred), or some other simple bit of code that will parse a USA/CA phone number into component parts, so:

6条回答
  •  悲&欢浪女
    2020-12-31 12:22

    here's a method easier on the eyes provided by the Z Directory (vettrasoft.com), geared towards American phone numbers:

    string_o s2, s1 = "888/872.7676";
    z_fix_phone_number (s1, s2);
    cout << s2.print();      // prints "+1 (888) 872-7676"
    phone_number_o pho = s2;
    pho.store_save();
    

    the last line stores the number to database table "phone_number". column values: country_code = "1", area_code = "888", exchange = "872", etc.

提交回复
热议问题