|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Regex to return only numbers
Hello!
![]() I have a string like: Code:
MyData 68309486 Bob How can I use regex in python to return only 68309486? Only the numbers? |
|
#2
|
|||
|
|||
|
|
|
#3
|
|||
|
|||
|
You can also use \d as a shortcut for [0-9], so "\d+" will work just as well.
|
|
#4
|
|||
|
|||
|
Thanks everyone
![]() |
|
#5
|
|||
|
|||
|
As I understand it, \s+ regex is the equivilent of saying "match 1 or more occurencies of any whitespace character" so the result it gives you; ' ' is correct
Edit: Ok you edited your previous post while I was responding, I'm not great with regexes but hopefully the above will answer the old question |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Regex to return only numbers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|