c# - Match all words from given string where words does not have only lower case letters or only upper case letters -
i retrieve words given string not caps , lower or first letter upper
for example in below sentence should extracted except first 4 words:
a abcd hello ajp
string str = "a abcd hello ajp lbl_description mhz assignexistinguseroptiontext _bthaudclassdrv_keyword a_dd actelismetaloop audenginestream_beginstreamswitch_enter audenginestream_begineos bo_th btnchange c_hange cds check_and_change_access_masks checkbox1 cimobjectpath ciscoislvlan comboemailaccounts d_elete csvfs_refs d_hcp dadornudreply decnet ipv4 kj kpa lalt ml n_o tabpage11 uapsd vlans ycbcr"
you can using split
method , linq:
var result = str.split(new[] {' '}, stringsplitoptions.removeemptyentries) .where(x => !x.all(char.isupper) && !x.all(char.islower) && !(char.isupper(x[0]) && x.skip(1).all(char.islower))) .toarray();
Comments
Post a Comment