我怎样才能在javascript中执行此操作?
$name = $xml->name;
$file_name = strtolower($name);
$file_name = str_replace(array('-',' ',' ','å','ä','ö'), array('',' ','-','a','a','o'), $file_name);
$file_name = preg_replace("/[^a-z0-9-]+/i", "", $file_name);
答案 0 :(得分:0)
toLowerCase() Converts a string to lowercase letters
toUpperCase() Converts a string to uppercase letters
replace() Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring
search() Searches for a match between a regular expression and a string, and returns the position of the match
答案 1 :(得分:0)
Mozilla有一个很棒的参考资料。我在下面的回复中提供了一些链接。
请查看toLocaleLowerCase以获得较低的字符串。然后转到replace,这在很多方面与preg_replace
非常相似,因为它主要基于正则表达式。
很多阅读,但它不应该太难!祝你好运!