Not able to post...
-
Hi. I tried posting a question in the “Help” section, but I got a message that Akismet considered the post content as spam!???
Anyone know the reason for this and how to overcome it?
Thanks,
David -
At one point spam was really bad so some forum plugins were put in place to help counter it. I have no idea how it works or what it looks for. Not sure if it detects suspicious links or weird characters/formatting. Maybe rewording or changing some links might help.
-
@dail, thanks - I’ll try it
In the meantime, can anyone remove the 3 attempted posts?
They are each named “Interesting behavior with string in python script”
They are broken - clicking on it just leads to an errorThanks,
David -
@dail, I just tried posting it again and I got the same problem.
I don’t know what to do to fix it - I will post a screenshot of my question herePlease let me know what you think
Thanks,
David -
can anyone remove the 3 attempted posts?
None of them show up for me.
To answer your actual question though…It is recommended to use raw strings in Python when writing regular expressions (some other languages have this type of feature as well).
Since “\s” and “\d” are not known escape sequences to Python then it treats “\s” as 2 separate characters (same with “\d”). However as you noticed “\b” is a known escape sequence so Python treats this as a single character: a backspace.
So your original python code could be written as:
mySearch = r"(command|function)\s+\d+\s+" + myWord + r"\b"
Notice the 2 "r"s before the strings. Technically it is not needed for the first string (it works fine with it there though) but I’ve found it to be good practice to always use raw strings when using regular expressions.
Luckily Notepad++ takes care of this for you when you use the Find/Replace so you normally don’t have to worry about this :)
-
@Dail - thanks! I didn’t know that
\b
was a special character in python!
Lesson learned - use raw strings… :)Thanks,
DavidP.S. Regarding those posts - that’s really weird! I see 3 posts in the “Need Help” section - all have 0 views…