不获取字符串的第一个字符并使用正则表达式获取括号中的数据

Not getting the first character of the string and get the data which is in a parenthesis using regex

主字符串:'Netflix|Prime Video|Disney+Hotstar|YoutubeOperating System: AndroidUltra HD (4K) 3840 x 2160 Pixels30 W Speaker Output60 Hz Refresh Rate3 x HDMI | 2 x USBA+ Grade1 Year'

  1. 正则表达式 (OTT) 代码:re.findall( r'^\w(.*?)O|U$', Tv_df['Features'][1]) o/p : ['etflix|Prime Video|Disney+Hotstar|Youtube']

  2. 正则表达式代码(类型):re.findall(r'[a-z]+\s(?:HD|SD)', Tv_df['Features'][1]) o/p : ['ltra HD', 'x HD']

P.S : 请找出上面的主串

  1. \w 移动到 ( 内,如:^(\w.*?)O|U$ 以匹配第一个字母。
  2. 你匹配的不是ultra的'U',你可以在开头加上[A-Z],而且你要匹配( & )里面的东西才能得到4K。您可以通过在末尾添加 \s\(.+?\) 来做到这一点。所以模式看起来像这样:[A-Z][a-z]+\s(?:HD|SD)