简体   繁体   中英

using java for replacing text in database

i am using replace method for editing text in mysql database and its working well for

every time i try to replace a string by some other string eg

    REPLACE(Eligibility_Points , '(ii)', 'second point is')";

works well for above case

but does not work well in the following case

    REPLACE(Eligibility_Points , '(ii)-(iii)', 'second and third point is')";

how should i fix this problem, thanks for your help

Assuming that this is the MySQL REPLACE string function you are talking about, the only reason I can see why the second example wouldn't work is that (maybe) the Eligibility_Points field (or whatever) doesn't contain the first string at all.

Maybe you could provide more context; eg what evidence you have that the replace isn't working.

However @vadchen makes a good point. If you do the replacement in the first example, then it will remove all examples that might trigger a replacement in the second example. Maybe you just need to do the "edits" in the reverse order.


There is no need to escape any of the characters in those fragments, either from the Java or SQL perspective.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM