How to avoid the lexical error when input data to derby?

穿精又带淫゛_ 提交于 2019-12-11 09:38:24

问题


I have some regular patterns values to be saved in derby. it includes a lot of delimited letter mentioned in the derby. How could I input this data to the derby?

insert into configuration_master (PROPERTY_ID,PROPERTY_KEY, PROPERTY_VALUE, PROPERTY_NAME , PROPERTY_DESCRIPTION , PROPERTY_VALIDATION  ,CATEGORY_1,CATEGORY_2,CATEGORY_3,FST_REG_DT,FNL_AMD_DT ) values( 'agent.dependency.urlpatterns','agent.dependency.urlpatterns',"
        \(\s*['"]#target['"]\s*\)\.attr\(\s*['"]action['"]\s*,['"]([\w]+\.do)['"]\)
        \.attr\(\s*['"]action['"]\s*\,\s*['"]([\w_/\?\=\&]+)['"]\s*\)
        a.href\s*\=\s*['"]([\w_/\?\=\&]+)['"]
        [\. ]action\s*\=\s*['"]([\w_/\?\=\&]+)['"]
        ['"]((/[\w\._]+)*/[\w\._]+\.do)['"]
        ['"]\S*\.html['"]
        (action|value|href)\s*=\s*['"]((\/[a-zA-Z0-9\$\{\}?=.]+){2,3})\/?['"]
        ",'agent.dependency.urlpatterns','','','DEFAULT','DEFAULT','DEFAULT','','')

回答1:


I'm not going to through that hideous regexp of yours and fix it all, but if you do want to insert it into your database, then:

  • Use single quotes (') to surround the entire regexp string. At the moment you are using double quotes (").
  • Use two single quotes inside a string to represent a single-quote character within the string. For example

     SELECT 'Don't do this' FROM some_table
    

    will fail with an error, but

     SELECT 'It''s better to do this' FROM some_table
    

    will select the string It's better to do this.



来源:https://stackoverflow.com/questions/30637137/how-to-avoid-the-lexical-error-when-input-data-to-derby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!