Hi, I have this code, I want it to remove all double spaces from the text area, but every time it only deletes the first event.
$(document).ready(function(){ $("#article").blur(function(){ ///alert($(this).val()); $(this).val($(this).val().replace(/\s\s+/, ' ')); }); });
I also tried removeAll (), but it does not work at all. thanks. I have a live example online at http://jsbin.com/ogasu/2/edit
Use the g modifier in your regular expression to match and replace globally:
/\s\s+/g
Otherwise, only the first match will be replaced.
, jQuery 1.4 val , :
val
$(this).val(function(index, value) { return value.replace(/\s\s+/g, ' '); });
$(this).val.
$(this).val
.replace(/\s\s+/g, ' '));
g
Source: https://habr.com/ru/post/1743012/More articles:Should you remove all warnings in your Verilog or VHDL design? Why or why not? - vhdlС# - получить путь к файлу из файла конфигурации - @не делает это волшебство - c#Can you use backlinks in the regex pattern part? - phpprogramming from a USB drive, .net - .netGetting text between quotes using regular expression - stringHow can I restore / reorganize my indexes on Sql Compact 3.5 SP1? - indexingSVNKit: как получить номер версии из рабочего каталога - svnkitDreamweaver CS4 Mac .inc color code - phpQuery the contents of the Windows Media Center library - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1743017/is-there-a-way-to-initialize-imagekits-iksaveoptions-to-default-to-tiff-with-lzw-compression&usg=ALkJrhh5IJyAH-BZqb-lnwGeEYZK4vaQnAAll Articles