By bathtubandatoaster


2019-07-11 19:11:13 8 Comments

I'm pulling different sections out of a string for a webscrapping project. my string im using regex on looks like this its currently the variable insidetext:

ABC Company (ABC) upgraded to neutral at BESTBANK; PT $18

I'm trying to get the first part of the before (ABC) so im using regex in Python.

companyname = re.match('.+?(?=[ ][(])',insidetext)

print(companyname)

this is the output it gives me

<re.Match object; span=(0, 20), match=' ABC Company'>

I just want the matched portion. Example I just want it to print ABC Company

What can I do to remove the re.Match object; span=(0, 20), match= section?

0 comments

Related Questions

Sponsored Content

21 Answered Questions

[SOLVED] How to print without newline or space?

  • 2009-01-29 20:58:25
  • Andrea Ambu
  • 1713878 View
  • 1676 Score
  • 21 Answer
  • Tags:   python newline

56 Answered Questions

[SOLVED] How to replace all occurrences of a string?

38 Answered Questions

[SOLVED] How to print colored text in terminal in Python?

12 Answered Questions

[SOLVED] How can I make a time delay in Python?

15 Answered Questions

[SOLVED] How to print to stderr in Python?

10 Answered Questions

[SOLVED] Does Python have a string 'contains' substring method?

33 Answered Questions

[SOLVED] How to get the current time in Python

  • 2009-01-06 04:54:23
  • user46646
  • 2837618 View
  • 2457 Score
  • 33 Answer
  • Tags:   python datetime time

5 Answered Questions

[SOLVED] How do I lowercase a string in Python?

11 Answered Questions

[SOLVED] How to substring a string in Python?

  • 2009-03-19 17:29:41
  • Joan Venge
  • 2570136 View
  • 1908 Score
  • 11 Answer
  • Tags:   python string

34 Answered Questions

[SOLVED] RegEx match open tags except XHTML self-contained tags

  • 2009-11-13 22:38:26
  • Jeff
  • 2593212 View
  • 1324 Score
  • 34 Answer
  • Tags:   html regex xhtml

Sponsored Content