Hi, let's say that I have such an array in javascript:
var arr = ["ftp_text_1", "abc_text_2", "ftp_text_3"];
How to remove all lines from my array starting with ftp_
ftp_
thanks
Just use Array.filter :
arr = arr.filter(function (item) { return item.indexOf("ftp_") !== 0; });
Edit: to support IE9 you can use jQuery.grep :
arr = $.grep(arr, function (item) { return item.indexOf("ftp_") !== 0; });
Use regex:
$.each(arr, function (index, value) { if (value.match("^ftp_")) { arr.splice(index, 1); } });
use temp array to store the desired string. for (i = 0; i <are.length; i + =) {if (! arr [i] .startesWith ('FTP _')) {Tempo [J] = arr [I]; J ++:} arr = pace; }
Source: https://habr.com/ru/post/1499679/More articles:Ember.js filters data from a dynamic route - javascriptHow to hide Android application from task switcher - androidHow do you prevent character escaping in knockout.js data binding? - javascriptAny reasons to avoid the Application.Worksheet function? - vbaVisual Studio 2012/2013 class member initialization - c ++What is the benefit of helpers in CodeIgniter? - phpOpenlayers print function - javascriptusing JSF EL expression inside web.xml - java-eeConnect to an existing Postgresql database using ActiveRecord without rails - ruby โโ| fooobar.comAdding a file to the jar during maven build - javaAll Articles