C++ MFC RegEx issue -


i using regex restrict characters entered textbox

i using below allowed characters

catlregexp<> regex; cstring cstext2 = "some test £" cstring m_szregex = "([a-za-z0-9\\.\\,\";\\:'@#$£?\\+\\*\\-\\/\\%! ()])"; reparseerror status = regex.parse(m_szregex, true);  catlrematchcontext<> mc; if (!regex.match(cstext2, &mc))  {      afxmessagebox("inavlid char") }        

this works fine, except £ symbol. doesn't seem pick up

can advise on missing

thanks

this seems bug affects extended ascii characters (those higher 0x7f).

the character value converted integer , used index kind of attributes array. since char signed, undergoes sign expansion, character above 0x7f cause overflow.

size_t u = static_cast<size_t>(static_cast<_tuchar>(* ((rechar *) sz))); if (pbits[u >> 3] & 1 << (u & 0x7)) 

you can find more discussions on topic here: catlregexp crashes pound sign!


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -