How to achieve global matching of strings without using rules, ignoring case?

topic description

because our requirement is a global matching replacement string, but the replacement string is randomly input by the customer, which may contain escape characters such as "()" and "/", so we choose not to use the regular expression

sources of topics and their own ideas

can be replaced globally with split and join, but there is no way to achieve case insensitivity

related codes

/ / Please paste the code text below (please do not replace the code with pictures)
function replace_string (s1mems2mems3) {

if(s2){
    s1 = s1.split(s2).join(s3);;
}
return s1;

}

what result do you expect? What is the error message actually seen?

case-insensitive implementation

Apr.24,2022

give you an idea:

  1. lowercase the target text and user input,
  2. record the starting position after matching lowercase user input in the lowercase target text. The indexOf (str,? position) method can be used to determine all occurrence locations.
  3. according to the location of the text recorded in the previous step, combined with the length of the matching text, truncate the original target text that does not need to be replaced. You can use the substring (start,?end) method to get an array.
  4. then reassemble the array you got in step 3 using join (replacement text).
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea9442-1f40.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea9442-1f40.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?