Relative Content

Tag Archive for pythonpython-re

python, best method to replace punctuation but keep special words intact

I am making a modulatory function that will take keywords with special characters (@&*%) and will keep them intact while all other punctation is deleted from a sentence. I have devised a solution but it is very bulky and probably more complicated than it needs to be. Is there a way to do this but in a much simpler way.

How can i find a list in a string ignoring any number of spaces and new lines in between each element?

I’m currently having an hard time solving and generalizing the following problem:
I have a table, which is stored as a nested list, and I have a text which contains the content of the table as well as other text.
I do not now how the table is convererted in string in the text exactly: sometimes there is a space separating the cells, sometimes a new line, sometime both and sometimes nothing.
My goal is to find the block of text containing the table and substituting it with a placeholder (i.e. table_1).

re.finditer find one pattern of multiple matches in a text file

I want to search for a pattern in text files and send the file where the match is found.
Using re.finditer because I have two matching lists (patterns and names of the files to email)
I want to send one file even if there are multiple matches.
Is this possible?