Answer the question
In order to leave comments, you need to log in
How to count headings in text in python?
Hello,
I'm new to python, please point me in the right direction. I have been with the program for a long time.
There are also sentences ending in !?. also headings as a separate sentence,
they
can be like
Grandfather Planted
a Turnip
Planted Grandfather Turnip Planted Grandfather Turnip
The expressions I made are not working. The last one was: r'[^\w*${0}.] - python 3 version, outputs all sorts of crap.
Answer the question
In order to leave comments, you need to log in
In [1]: import re
In [2]: t = """Посадил дед репку
...: ПОСАДИЛ ДЕД РЕПКУ
...: Посадил Дед Репку"""
In [3]: re.findall('Посадил дед репку', t)
Out[3]: ['Посадил дед репку']
In [4]: re.findall('Посадил дед репку', t, flags=re.IGNORECASE)
Out[4]: ['Посадил дед репку', 'ПОСАДИЛ ДЕД РЕПКУ', 'Посадил Дед Репку']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question