Using regex extract all digit and word numbers
<p>I am trying to extract all string and digit numbers from  a text.</p>

<pre><code>text = 'one tweo three 10 number'
numbers = "(^a(?=\s)|one|two|three|four|five|six|seven|eight|nine|ten| \
          eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen| \
          eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty| \
          ninety|hundred|thousand)"

print re.search(numbers, text).group(0)
</code></pre>

<p>This gives me first words digit. </p>

<p>my expected result = ['one', 'two', 'three', '10']</p>

<p>How can I modify it so that all words and well digit numbers I Can get in list?</p>

<p>Well the re.findall and the add of [0-9]+ work well for your list. Unfortunately if you try to match something like seventythree you will get --> seven and three, thus you need something better than this below :-)</p>

<pre><code>numbers = "(^a(?=\s)|one|two|three|four|five|six|seven|eight|nine|ten| \
          eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen| \
          eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty| \
          ninety|hundred|thousand|[0-9]+)"

x = re.findall(numbers, text)
</code></pre>

python regex