Python Regex pattern not being matched?

The regex looks for ITEM followed by a letter then followed by exactly one word character (the w in the regex) You probably meant something like ITEM.(?Pa-zA-Z\w*) (note the added asterisk). This will look for ITEM followed by a letter then followed by zero or more word characters Also, it's a good idea to use raw strings for regular expressions to avoid hard-to-spot bugs: r"ITEM.(?Pa-zA-Z\w*) = (?P. *) (note the r prefix).

The regex looks for ITEM. Followed by a letter then followed by exactly one word character (the \w in the regex). You probably meant something like ITEM.(?Pa-zA-Z\w*)... (note the added asterisk).

This will look for ITEM. Followed by a letter then followed by zero or more word characters. Also, it's a good idea to use raw strings for regular expressions to avoid hard-to-spot bugs: r"ITEM.(?Pa-zA-Z\w*) = (?P.

*);" (note the r prefix).

Thanks, that has worked perfectly! I'm just starting to get my head around regex. – H4Z3Y Oct 13 at 12:41 2 @H4Z3Y: I've just added a note about raw strings.

I think it's a good habit to get into. – aix Oct 13 at 12:48 alright, cheers, I've done that in now – H4Z3Y Oct 13 at 12:50 +1 for raw strings. This is such a good idea that python should really just enforce it, since that seems to be a big part of their design philosophy anyway.

– andronikus Oct 13 at 13:36.

Accepted answer is right. Minor tweaks... escape the ". " after ITEM to mean a "." and not just anything usually a good idea to allow for more than one space (or no spaces) around the "=" r"ITEM\.(?Pa-zA-Z\w*) *= *(?P.

*? ).

I think escaping the spaces just as you did with the dot is a good idea too. – heltonbiker Oct 13 at 13:54 Agreed the best is to replace the " *" with "\s*" ... better regex but a little less readable ... like regex is ever readable – Phil Cooper Oct 13 at 14:09 Actually I meant \ (with the space character), but I think in the end there is indeed a lot of "space" (pun intended) for personal preference ;o). So it would become r"ITEM\.(?Pa-zA-Z\w*)\ *=\ *(?P.

*? ) *;" (formatting removed one space :o( – heltonbiker Oct 13 at 19:17.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions