Good something, everyone. I have a kind of an SQL code (which is irrelevant for the matter) in which I'd like to find a number + "," + some string in Russian (my test string is "в"). Here's an example of a string in which I hope to find this:
insert into lemmas (id, word, lemma) values ("37","возбраняется","возбраняться");
Here's my code in python:
file_SQL = open('sql_code.txt', 'r', encoding = 'UTF-8')
SQLtext = file_SQL.read()
regux = '([0-9]+)?","' + wordform.lower() #wordform is "в"
find_it = re.search(regux, SQLtext)
found_it = find_it.group(1)
file_SQL.close()
return found_it
In the end, I want to get the particular number. The error I get with this code:
Traceback (most recent call last):
File "C:\Users\Неро\my_study\homework_4_2016\holy_guacamole_SQL.py", line 109, in <module>
main()
File "C:\Users\Неро\my_study\homework_4_2016\holy_guacamole_SQL.py", line 106, in main
imma_write_myself_a_SQL_file(val4, val3)
File "C:\Users\Неро\my_study\homework_4_2016\holy_guacamole_SQL.py", line 85, in imma_write_myself_a_SQL_file
f_id = find_f_id(wrdform)
File "C:\Users\Неро\my_study\homework_4_2016\holy_guacamole_SQL.py", line 95, in find_f_id
found_it = find_it.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
Obviously, this means that re.search()
found nothing.
I've also tried to just search with this regular expression in notepad++, but it didn't work:
A picture of me trying to find this number before a word starting with "в".
(Sorry for the Russian notepad, hope nobody minds it) As you can see in the picture a word starting with "в" exists in the file.
Also I've tried several other regular expressions such as ([0-9]+)?\",\"
, ([0-9]{1,3})","
.
And I've tried to search with re.findall()
, but I basically got an empty list.