Issue 10539: Regular expression not checking 'range' element on 1st char in string. (original) (raw)

Created on 2010-11-26 15:34 by TxRxFx, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
RegExPyBug.py TxRxFx,2010-11-26 15:34 Simple example showing false positive on omitted 1st char in word char range limits on expression's 1st part.
unnamed TxRxFx,2010-11-26 19:05
Messages (4)
msg122461 - (view) Author: Jamie Murray (TxRxFx) Date: 2010-11-26 15:34
The first char in a word is omitted from being checked against the 'range' element of the 1st part of this expression. The second char is properly checked to see if it's in range # Desired safe string to expect goodString = "f42e6be1-29bf-4f3c-ba58-1ae1d9ca5f88" # Test string to return False if it's not within reg ex range. # but still returns a false positive even though the g at the start is outside of a-f range. badString = "g42e6be1-29bf-4f3c-ba58-1ae1d9ca5f88" # 2nd test string which does return a false result correctly. otherBadString = "fg2e6be1-29bf-4f3c-ba58-1ae1d9ca5f88" See attached file for example. "Python 2.5.4 (r254:67916, Dec 23 2008, 15:19:34) [MSC v.1400 64 bit (AMD64)] on win32"
msg122471 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-11-26 18:37
I'm not sure I understand. The output I get is: f42e6be1-29bf-4f3c-ba58-1ae1d9ca5f88 g42e6be1-29bf-4f3c-ba58-1ae1d9ca5f88 False The first string matches. The second string matches because the leading "g" is being matched by "\w". The third string does not match because the "g" in the second position is not matched by "[0-9][a-f]". For the second string you're matching "\w" followed by 7 "[0-9][a-f]", just as the regex allows. Am I missing something?
msg122473 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-11-26 18:51
I don't think so; closing as invalid.
msg122474 - (view) Author: Jamie Murray (TxRxFx) Date: 2010-11-26 19:05
Apologies, sincere and most humble apolgies doh! On 26 Nov 2010 18:51, "Georg Brandl" <report@bugs.python.org> wrote: > > Georg Brandl <georg@python.org> added the comment: > > I don't think so; closing as invalid. > > ---------- > nosy: +georg.brandl > resolution: -> invalid > status: open -> closed > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue10539> > _______________________________________
History
Date User Action Args
2022-04-11 14:57:09 admin set github: 54748
2010-11-26 19:05:38 TxRxFx set files: + unnamedmessages: +
2010-11-26 18:51:44 georg.brandl set status: open -> closednosy: + georg.brandlmessages: + resolution: not a bug
2010-11-26 18:37:00 eric.smith set nosy: + eric.smithmessages: +
2010-11-26 15:34:02 TxRxFx create