JavaScript arrays, string-related operations

Source: Internet
Author: User

Task description

L Upgrade based on task IV

L change the new element input box from input to textarea

l Allow batch input of multiple content, format can be number, Chinese, English, etc., can be used by carriage return, comma (full-width half-width can be), comma, space (full-width half-width, tab, etc.) and other symbols as different content interval

L Add a query text input box, and a Query button, when you click on the query, the query words in the content of each element to do fuzzy matching, the match to the content of the special identification, such as text color. For example, the content has ABCD, the query word is AB or BC, then the content needs to identify

<textarea> tags define multiple lines of text input controls

<id= "num"  name= "num"  rows= ""  cols ="" ></ textarea >

Enter multiple content, multiple symbol intervals.

Stringobject.split (Separator,howmany) can be used to split a string. Separator can be

A string or regular expression, with a carriage return, a comma, a comma, and an empty number for segmentation, is naturally used in regular expressions. Here is a regular quick look at the table: http://www.jb51.net/shouce/jquery1.82/regexp.html

Enter: \ r; comma:, comma:, empty number: \s;

Num.split (/[,\s, \r]/);

Let num = document.getElementById ("num"). Value;             var arr=[];             = Num.split (/[,\s, \r]/);              for (Let i = 0;i<arr.length;i++) {                  // corresponding data processing             }

When you click on a query, the query words are blurred in the content of each element.

First, make a query input box and button

<name= "SearchText"  rows= " cols=" "  ></textarea><id= "Search"  > Query </button>

The event is then bound to the Query button, and the event can be queried to see if there is a matching unit in Li.

Search.addeventlistener ("click",function() {               = searchtext.value;                 for (Let i= 0;i<data.length;i++) {                                  if(data[i].search (text) ===0) {                          = "Yellow" ;                    }               }});
Complete code: https://github.com/moeeliu/ife/blob/master/js6.html

JavaScript arrays, string-related operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.