python - How to escape rethinkdb regex pattern for r.match -


i want search r.match in rethinkdb using user input - whole user input should treated search pattern. i'm creating regex based on user input this:

pattern = u'.*(?i){0}.*'.format(user_input) 

but if user inputs '[' or ']' or other special character got errors rethink this:

error in regexp .*(?i)\u0141[.* (portion [.*): missing ]: [.* in:

is there way escape regex rethinkdb? have tried use python re.escape fail when combining unicode errors one:

error in regexp .*(?i)\\u0141.* (portion \\u0141): invalid escape sequence: \u0141

any suggestions?

use re.escape() function this:

re escape

escape(string)

return string non-alphanumerics backslashed; useful if want match arbitrary literal string may have regular expression metacharacters in it.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -