I am looking to find bcrypt hash string using regex (in PowerGrep), in a database.
Tried this regex:
{?A-Za-z_0-9.{60}}?
But no match w
Update:
Since beside the y value there might be a or b, you may use
^\$2[ayb]\$.{56}$
See the regex demo online. Details:
^ - start of a string\$ - a literal $ char (it should be escaped in a regex pattern to match a literal $ char, else, it will denote the end of string)2 - a 2 char[ayb] - a character class matching any single char out of the specified set\$ - a $ char.{56} - any 56 chars other than line break chars (if not POSIX compliant regex engine is used, else, it will match any chars; to match any chars in common NFA engines, replace . with [\s\S] or use a corresponding DOTALL flag)$ - end of string.Original answer
Your regex - {?A-Za-z_0-9.{60}}? - contains ranges not inside a character class [...], but inside optional curly braces, and thus they present sequences of literal characters. See your regex demo to see what I mean.
You can use the following regex:
^\$2y\$.{56}$
See demo
The ^ matches the start of string, \$2y\$ matches $2y$ literally (as $ is a special character and needs escaping) and .{56} is the rest 56 characters.