Domanda

I am trying creating a MS-Access database programmatically from Sqlite sentences in Visual Basic 2008, and as word "password" is a field reserved word, I have to replace it by "[password]" and it works fine. The problem is, there is field names with "password" word embedded as "2nd_password" or "password_3rd" for example, in this case doesn't necessary replace "password"

So I am searching the following results:

 password -> [password]
 2nd_password -> 2nd_password
 password_3rd -> password_3rd

I've tried searching the pattern "(space)password(space)" but it doesn't work.

 Regex.Replace(query, ":bpassword:b", " [password] ")

Thanks in advance.

È stato utile?

Soluzione

Just looking here it seems like in VB you still use \b not :b

 Regex.Replace(query, "\bpassword\b", " [password] ")

Altri suggerimenti

Please try this one as well apart from \b:

(?<!\w)password(?!\w)

Thins one is checking a non alphanumeric(a-z A-Z 0-9 _) characters on left and right side of the password.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top