This article describes how to replace spaces, line breaks, Chinese commas, and other regular expressions with English commas.
In the process of development, you will often encounter a need to provide an input box for others, and then others enter some ID or keyword, such as the wordpress background tag input box:
This is just a comma in the English state. what if someone accidentally enters a comma in the Chinese state? What about decimal point?
So I wrote an expression with a regular expression and replaced the line break with a space with a comma.
Replace the submitted id with a space newline character with a comma, and then use the explode function to switch to an array.
The code is as follows:
$ Ids = $ _ POST ["ID"];
$ Id = preg_replace ("/(\ n) | (\ s) | (\ t) | (\ ') | (,)/",', ', $ ids );
$ Topicids = explode (",", $ tids );
This adds a decimal point filter.
The code is as follows:
$ Ids = preg_replace ("/(\ n) | (\ s) | (\ t) | (\ ') | (,) | (\.) /", ',', $ ids );
OK. after such processing, there will be no problem.
Tip: in fact, it is a better choice for Xiaobian to handle this problem before submitting JavaScript code.