I have a pattern matching code in Java, which gets the pattern from database
When I was doing JUnit with mysql database everything went pretty cool
Original Pattern in database
[a-zA-Z]{1}[0-9]{2}[a-zA-Z]{3}[0-9]{5}_[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}\\.csv
Mysql is retruning as expected and as it's stored.
Oracle is returning with extra backslashes
[a-zA-Z]{1}[0-9]{2}[a-zA-Z]{3}[0-9]{5}_[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}\\\\.csv
Why it’s returning differently. Between am using hibernate to fetch the data.
In MySQL,
\is the escape character for strings, but that’s not true in Oracle. That means that this insert will work differently for each of them:That will insert
\\in MySQL but\\\\in Oracle. If you want to insert only\\in Oracle, you have to change the insert to this: