The following update statement executes to replace test with abc



update test set
url=replace ("www.test.com", "test", "abc")
where url regexp;

If on record,There are similar

To change all these records, execute the SQL statement as follows

update test set
url=replace ("www.test.com", "test", "abc")
where url regexp "^ (www.test)";

Regex is very flexible,But there are very complicated situations,Regular efficiency is not necessarily higher than other methods,Do not have to hold a tree dead,Sometimes trying new methods may learn more.

  • Previous Detailed encapsulation and inheritance of PHP classes
  • Next Unicode matching special characters for regular expressions