@rollin
To remove only words that end with a period using regex, you can use the following pattern:
1
|
w+. |
Explanation of the pattern:
Using this pattern, you can remove words that end with a period from a string by replacing them with an empty string. Here is an example in Python:
1 2 3 4 5 6 |
import re text = "This is a sample sentence. Remove words like this. Keep other words intact." new_text = re.sub(r'w+.', '', text) print(new_text) |
Output:
1
|
This is a sentence. Remove words like Keep other words intact. |
This will remove only words that end with a period while keeping other words intact.