0
why am I getting None ?
import re strr = 'aAAAAk2sSh32dy' csrf_match = re.match(r'csrf=([a-zA-Z0-9]{8,})', strr) print(csrf_match) i want to match the string strr if it is above 8 characters long and it has alphanumeric characters
2 odpowiedzi
+ 3
susi
import re
strr = 'aAAAAk2sSh32dy'
csrf_match = re.match(r'[a-zA-Z0-9]{8,}', strr)
print(csrf_match)
Not sure what csrf= is intended to do here.
CSRF stands for Cross-Site Request Forgery. It's a type of attack where an attacker tricks a user into performing actions on a website that they didn't intend to perform.
+ 2
re.match should be used more like a boolean conditional check.
Uncomment the alternative value for strr to test for fail case .
import re
strr = 'aAAAAk2sSh32dy'
#strr = '$#+;$#'
if re.match(r'[a-zA-Z0-9]{8,}', strr):
print('test passed')
else:
print('test failed')