Python re to separate some data values

2021-04-28 Thread Bruce Labitt
If someone could suggest how to do this, I'd appreciate it.  I've scraped a table of fine thread metric screw parameters from a website.  I'm having some trouble with regex (re) separating the numbers.  Have everything working save for this last bit. Here is a sample string: r1[1] = '

Re: Python re to separate some data values

2021-04-28 Thread Henry Gessau
On 4/28/2021 17:57, Bruce Labitt wrote: > I've looked in https://www.w3schools.com/python/python_regex.asp, > https://docs.python.org/3/library/re.html, > https://docs.python.org/3.8/howto/regex.html, > https://www.guru99.com/python-regular-expressions-complete-tutorial.html#2, >

Re: Python re to separate some data values

2021-04-28 Thread Bruce Labitt
On 4/28/21 6:28 PM, Joshua Judson Rosen wrote: > On 4/28/21 5:57 PM, Bruce Labitt wrote: >> If someone could suggest how to do this, I'd appreciate it.  I've >> scraped a table of fine thread metric screw parameters from a website. >> I'm having some trouble with regex (re) separating the numbers. 

Re: Python re to separate some data values

2021-04-28 Thread Bruce Labitt
On 4/28/21 6:35 PM, Henry Gessau wrote: > On 4/28/2021 17:57, Bruce Labitt wrote: >> I've looked in https://www.w3schools.com/python/python_regex.asp, >> https://docs.python.org/3/library/re.html, >> https://docs.python.org/3.8/howto/regex.html, >>

Re: Python re to separate some data values

2021-04-28 Thread Joshua Judson Rosen
On 4/28/21 5:57 PM, Bruce Labitt wrote: > If someone could suggest how to do this, I'd appreciate it.  I've > scraped a table of fine thread metric screw parameters from a website.  > I'm having some trouble with regex (re) separating the numbers.  Have > everything working save for this last

Re: Python re to separate some data values

2021-04-28 Thread Joshua Judson Rosen
On 4/28/21 7:01 PM, Bruce Labitt wrote: > On 4/28/21 6:28 PM, Joshua Judson Rosen wrote: >>> re.search('(\.)\d{3,3}', r1[1]) returns >>> so it found the first instance. >>> >>> But, re.sub('(\.)\d{3,3}', '(\.)\d{3,3}, ', r1[1]) yields a KeyError: >>> '\\d' (Python3.8).  Get bad escape \d at