1

Consider you have the following text:

yada yada 
yada yada 1
;


<Hello.There>yada:EGHKJHKG, Source:QWEKGHGHJGKGHJKGHJKVMVNMVMVMVMVMVMVMBTDFHG, </Hello.There>
yada2
yada3

I want to be able to take the information after Source: and before , only.

I've managed to do it with this site , and matched the source value My regex expression is:
<Hello.There>.+Source:(.+?),\s*</Hello.There>

My python code is:

match = re.match(r'<Hello.There>.+Source:(.+?),\s*</Hello.There>
I get None for match after this line, any ideas?
(I tried many more regex options without success)

JavaSa
  • 5,813
  • 16
  • 71
  • 121

1 Answers1

4

re.match matches only at the beginning of the string. You need to use re.search if you want to match not only at the beginning.

>>> import re
>>> re.match('llo', 'hello')   # only match at the beginning
>>> re.search('llo', 'hello')  # match anywhere
<_sre.SRE_Match object at 0x00000000029BA4A8>

See search() vs. match() from the Python re module documentation.

falsetru
  • 357,413
  • 63
  • 732
  • 636