Python Regex problems finding Caret ('^') -


i have problem regex in python 3.2

i want make sure string matches critera letter (or number) symbol.

answer = bool(re.findall('[a-z|1-9][^a-z|1-9]',string)) 

this works expected. if test a# true , works types of enteries. accept when such t^ returns false. same no matter letter comes before caret. problem regex or python?

there answers here none have picked in ^ used in character class, means not of these things, [^a] letter a. saying `"none of things after ^ , before nearest not-escaped ]"

as mentioned or thing ... character class 1 big or!

[\^a] matches ^ or a. careful though, backslash taken "the letter backslash" unless escapes something, example \k backslash , k, \n newline, \\n backslash (the letter) n.

php not nice. need "\\\\" letter backslash, given thing after backslash can escaped (which regex engine works out), php not use "oh can't escape k, must therefore mean letter backslash followed k", discards backslash.

so many hours... just... awful.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -