Keep the first match and remove the rest match from file
sed 'PATTERN\s*$/d' -i path_to_file
Tuesday, August 8, 2017
Wednesday, August 2, 2017
Python regex
#!/usr/bin/python
import re
regexPattern = re.compile('^(?!\\/usr\\b|\\/var)(\\/[\\w]+)+\\/?$')
inputString = [ "/", "/usr", "/var", "/test" ]
for v in inputString:
m = re.match(regexPattern, v)
print("")
print("Test String " + v )
if m:
print("Full Match" + m.group())
print("Pass")
else:
print("No Match")
Subscribe to:
Posts (Atom)