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

Main string : '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. code of regex (OTT): re.findall( r'^\w(.*?)O|U$', Tv_df['Features'][1]) o/p : ['etflix|Prime Video|Disney+Hotstar|Youtube']

  2. code of regex (Type): re.findall(r'[a-z]+\s(?:HD|SD)', Tv_df['Features'][1]) o/p : ['ltra HD', 'x HD']

  • The output for OTT regex is correct but the first charcter 'N' is missing.
  • The output for type regex should be Ultra HD (4K) . I'm facing the same problem that is the first character 'U' is missing and the data '4K' should be extracted which is in the paranthesis.

P.S : Please find the main string above.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source