0

I have an html file that I am reading the below line from. I would like to grab only the number that appears after the ':' and before the ',' using REGEX... THANKS IN ADVANCE

"totalPages":15,"bloodhoundHtml"
hwnd
  • 69,796
  • 4
  • 95
  • 132
Jonathan Scialpi
  • 771
  • 2
  • 11
  • 32

3 Answers3

1
"totalPages":([0-9]*),

You can see the Demo here

Then the python code is

import re

p = re.compile('"totalPages":([0-9]*),')
print p.findall('"totalPages":15,"bloodhoundHtml"')
Jan Moritz
  • 2,145
  • 4
  • 23
  • 33
0

you can try :\d+, to get the ':15,' then you can trim first':' and trim end ',' to get the pure numbers, I don't know if python can use variable in the regex, I'm a c# programe, in c#, I can use :(?<id>\d+), to match this string, and get the number directly by result.group["id"]

0
:\d{1,},

Also works for parsing the line you gave. According to this post, you might run into some trouble parsing the HTML

Community
  • 1
  • 1
Mark S.
  • 301
  • 1
  • 4
  • 10