简体   繁体   中英

How can I escape string with a regex?

How can I escape a string to improve queries in MySQL.

I need add ` (crass) in names of tables with name of fields separatly by dot.

But sometimes exists more than one

Examples of my strings

How write a regex to do this

Table.field Table . field // <-- need this

FORMAT(Table.field + Table2.field2 - Table3.field3, 2)
FORMAT(`Table`.`field` + `Table2`.`field2` - `Table3`.`field3`, 2) // <-- need this

DATE(Table.field)
DATE(`Table`.`field`) // <-- need this

Table.field > Table2.field
`Table`.`field` > `Table2`.`field` // <-- need this

查找:(\\ w +)。(\\ w +)...替换:$ 1. $ 2 – Tim Biegeleisen

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