问题
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