-1

trying to write the appropriate regex expression to capture barometric pressure with two string possibilities. looking to simply grab the float values and remove the "in" string.

The String possibilities are (examples): '30.01in' or '30in'

my current expression (see below) works for the former (30.01), but fails to grab the float in the latter (30in)

re.compile('[0-9]?[0-9]\...')
Amocat _
  • 41
  • 4
  • You don't really need a RegEx for that, just replace 'in' with ''. – Poul Bak Aug 28 '18 at 20:30
  • 1
    @Wiktor Stribiżew would you mind to close all the possible dupes that you have answered? With due respect ,seems like only a hight repo user is allowed to answer possible dupes in regex tag, keep it up – Pavneet_Singh Aug 28 '18 at 20:42
  • 1
    @Pavneet_Singh I stopped answering evident dupes after getting 45K. [I remove my dupes](https://stackoverflow.com/questions/47396693/regular-expression-for-word-or-any-prefix-of-same-word). Just go and close those you think are outright dupes, SO users will do the rest. – Wiktor Stribiżew Aug 28 '18 at 20:59
  • @WiktorStribiżew hmm maybe there could be a slight amount of miss anyway, nah I am good , thanks for the suggestion, though I appreciate and admire your skills and passion, keep it up! – Pavneet_Singh Aug 28 '18 at 21:02
  • Aw its love above – Amocat _ Aug 29 '18 at 00:00
  • Send duplicate thread – Amocat _ Aug 29 '18 at 00:27

1 Answers1

-1
(\d+(?:\.\d+)?)in

This should capture ints or floats

Mark B
  • 581
  • 2
  • 14