0

How to match the text starting with a space. I know the question is not proper. Please check out the description

I have a ScrolledText widget in and i want to check if the user has input anything or not. The problem is that if I do: #here Content is the ScrolledText widget # and 'e' is its value Regex = re.compile('\w') If Regex.fullmatch(e) is None: messagebox.showwarning('Warning ','you have not entered anything ') And if the user starts his entry with a space, it still shows the messagebox.showwarning. Thanks

24th Oct 2020, 1:05 PM
Fact Finder
Fact Finder - avatar
2 ответов
+ 2
r'^\s*
#x27; ^ means starts with \s means spaces like \n\t... * zero or more occurences $ ends with **edit** your code may look like: pattern = re.compile(r'^\s*
#x27;) if not re.findall(pattern, e): . . .
24th Oct 2020, 1:10 PM
QTWizard
0
Thanks a ton. My whole code was stuck because of this. Thanks.
24th Oct 2020, 4:29 PM
Fact Finder
Fact Finder - avatar