Python Forum
using the reg expression split to get the words
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using the reg expression split to get the words
#1
Hi ,

I am having a string like A(B,C) .

I want to read A B C separately .

I tried below code with class name as "G(A, B)"

 52 if (re.match("[a-zA-Z0-9]\([a-zA-Z0-9]",classname)):
 53            print("++++++++++")
 54            result=re.split("[a-zA-Z0-9]\([a-zA-Z0-9]",classname,0)
 55            print(classname)
 56            print(result)
++++++++++
G(A, B)
['', ', B)']

Trying to know how to fetch G and A from here.

Your inputs would be highly appreciated.
Reply


Messages In This Thread
using the reg expression split to get the words - by vlrk - May-10-2020, 05:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Regular Expression for matching words xinyulon 1 2,272 Mar-09-2022, 10:34 PM
Last Post: snippsat
  Generate a string of words for multiple lists of words in txt files in order. AnicraftPlayz 2 3,006 Aug-11-2021, 03:45 PM
Last Post: jamesaarr
  Pass results of expression to another expression cmdr_eggplant 2 2,429 Mar-26-2020, 06:59 AM
Last Post: ndc85430
  Read re.split expression NewBeie 2 2,213 Apr-25-2019, 12:12 PM
Last Post: NewBeie
  Compare all words in input() to all words in file Trianne 1 2,871 Oct-05-2018, 06:27 PM
Last Post: ichabod801
  Use regular expression to return 5 words before and after target word. steve1040 2 13,145 Sep-28-2017, 08:45 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020