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
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):
.
.
.
0
Thanks a ton. My whole code was stuck because of this. Thanks.