Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7936441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:13:00+00:00 2026-06-03T22:13:00+00:00

I’m writing a small script that will match a shoe size from a shoe

  • 0

I’m writing a small script that will match a shoe size from a shoe identifier ( SKU ).

There’s a few cases that i want to be able to handle. Given the following list:

sizes = ['315122-603 10  A', '315122-608_12.0', '317982-019', '364781-019_5.5Y', 'V24088-001_10', '609048-035  8.5', '7-20Spm8231B5 10', 'G17295-001_9.5']

i want to be able to get the size for each like (10,12,5.5,etc..).

My knowledge of regular expressions is very limited, i have been looking for some snippets here and there and came up with the following

r = '\d{1,2}.\d+'
for size in sizes:
    re.findall(r, size)

['315122', '603']
['315122', '608', '12.0']
['317982', '019']
['364781', '019', '5.5']
['24088', '001']
['609048', '035', '8.5']
['7-20', '8231', '5 10']
['17295', '001', '9.5']

but as you can see it doesn’t work. I want to be able to match only the number before the decimal and after the decimal but only the numbers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:13:01+00:00Added an answer on June 3, 2026 at 10:13 pm

    A few problems:

    • The . has a special meaning in a regular expression. If you literally want to match a dot you need to escape it.
    • You probably want the dot to be optional.
    • Check to see that there are no more digits before or after the match by using techniques such as \D, \b or (?!\d).
    • You should usually use raw strings to write regular expression patterns, so that the backslash sequences aren’t interpreted as control characters.
    • re.findall finds multiple matches. If you know there’s only going to be one match, use re.search.

    Try this:

    pattern = r'\D(\d{1,2}(?:\.\d+)?)(?!\d)'
    

    Note that some of your strings contain underscores or no decimal separator. You haven’t really described what should happen in these cases, and this pattern won’t handle all the cases in your example, but it will hopefully give you a good start.

    You may also want to consider writing a different regular expression for each input type rather than trying to write a single regular expression to handle all possible inputs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.