Regex - regular expressions in Python | real world examples for Web Scraping and extracting PDF text

preview_player
Показать описание
regex examples - Sooner or later you will need to resort to using regular expressions if you are scraping text. This video will show you some useful Python (version 3) examples which you can use over and over again.

The first 2 regex examples, "look behind" and "look ahead" and this makes them very useful, and worth learning, even if you don't want to learn the nitty gritty of regular expressions.


Also, the code below is shown working at 23:46

Note 'd' means 'digit' and not 'decimal' in regex (my bad!)

Example regex made in the video, to get just the 'digits' of the 'height' (and not the 'm') :
======================================================================

import re

tx = "The apple tree is small to medium in size, measuring up to 10m high. \
Look out for: its leaves, which are slightly woolly above and densely \
woolly below; and its large green to 5 cm high red fruits."

print(treeheight)

===================================================

Subscribe to the YouTube Channel
=================================

Follow on Twitter - to get notified of new videos
======================================

Code Monkey King's awesome Chess Game :
===============================================

Buy Dr Pi a coffee (or Tea)

Thumbs up yeah? (cos Algos..)

Proxies
=================================================
If you need a good, easy to use proxy, I was recommended this one, and having used ScraperAPI for a while I can vouch for them. If you were going to sign up anyway, then maybe you would be kind enough to use the link and the coupon code below?

You can also do a full working trial first as well, (unlike some other companies). The trial doesn't ask for any payment details either so all good! 👍

◼️ Coupon Code: DRPI10
(You can also get started with 1000 free API calls. No credit card required.)

#python #regex #lookbehind #lookahead
Рекомендации по теме
Комментарии
Автор

Hello Dr pi, i have a list whose all values are strings. L = [ 'file2', 'file3', 'file1' 'file_witout_number']

I want to sort them like L = [ 'file1', 'file2', 'file3' 'file_witout_number']

samiullah