Alibabacloud.com offers a wide variety of articles about fuzzy string matching javascript, easily find your fuzzy string matching javascript information here online.
Example:
Var src = "images/off_1.png"; alert (src. substr (); // the pop-up value is: off.
Function: split ()
Function: uses a specified separator to split a string and store it in an array.
Example:
Str = "jpg | bmp | gif | ico | png"; arr = theString. split ("|"); // arr is an array containing character values "jpg", "bmp", "gif", "ico", and "png"
Function: John ()
Function: combines an array into a string
I recently checked the JavaScript data and found a function:
Copy Code code as follows:
function format (s)
{
var args = arguments;
var pattern = new RegExp ("% ([1-" + Arguments.length + "])", "G");
return String (s). Replace (Pattern,function (word,index) {
return Args[index];
});
}
Test
window.onload = alert (Format ("and"%1 want to know whose%2 "," Papers "," shirt ","
capitalize; localecompare (parameter) compare two stringsStr1.localecompare (str2) str1 The first letter of the parameter str2 in front of the return value is-1;in the back 1;same 0; Replace used to replace a matching substring (in general, only the first match); "abbc". Replace ("b", "w") The latter replaces the former and the result is "awbc""abbc". Replace ("bb", "w") The latter replaces the former and the result is "awc"Match returns an array of
This is a problem that came about two years ago when I was doing the first real site in my life.
The site uses a back-and-forth separation method that returns JSON data from the REST of the backend and renders the front-end to the page.
Like many beginner Javascript novices, I used to embed the JSON data in HTML in the form of a concatenation string. There is less code at the start and is acceptable for t
);Console.log (str);//lo world!//hello world! 8:indexof a specified string value Searchvalue where it first appears in the string. Stringobject.indexof (Searchvalue,fromindex)Fromindex refers to the position in the string where the search begins.the retrieved string value does not appear, returning-1. var str= "Hello w
New String ("ABCCBA"); document.write (Str.indexof (' B ')); // Output 1 document.write (str.lastindexof ("BC")); // Output 1 Use this method to implement the contains effect to determine whether a string contains another string: 5. LASTINDEXOF () looks for the position of a character or
Grammar①indexof: Method returns the position of the first occurrence of a specified string value in a long string. If the lookup string is not found, return-1.IndexOfDescription: The method will retrieve the string stringobject from beginning to end to see if it contains substring searchvalue. The location at which to
JavaScript language essence of string common method analysis 1. String Common Method Analysis 1.1 String.prototype.slice ()The slice (start,end) method copies part of a string to construct a new stringWhen startThe end parameter is optional and the default value is String.Length. If endvar text= ' and in it he say "any
() converts all strings to lowercase 9. Str.trim () Strips the beginning and end of a string. Str.split ([separator][, limit]) returns an array where the delimiter separator can be a string or regular expressionvar str = "Hello?" world! " // ["Hello? world! "] // ["H", "E", "L", "L", "O", "?", "W", "O", "R", "L", "D", "!"] // ["Hello", "world!"] // ["H", "E", "L", "L", "O"]Str.match (RegExp)Returns an ar
the matching arrays (except for the capture group). For the regular exec, you can judge down step by step to determine whether it is null.
All lastindexes of reg are available.
2. string. slice (start, end), the end parameter is equal to the position of the last character you want To take + 1. If you want to get the nth character starting from position p, use string
argument to 0.var str = "Hello World" alert (Str.slice ( -3)),//rldalert (str.substring ( -3)),//hello Worldalert (Str.substr (-3));// Rldalert (Str.slice (3,-4));//lowalert (Str.substring (3,-4));//helalert (Str.substr (3,-4));/"" (Empty string)3 String Position methodIndexOf () lastIndexOf () accepts two parameters, the character to search for and the starting positionString.IndexOf (' a ')//a indicates
String ObjectTwo types of String objects are createdvar a= "Hello";var b=new String ("Hello");Here's howCharAt () Find characters in a string based on subscript Alert (A.charat (3));//Returns a character string according to the subscript Alert (A.charat (10));//empty
In JavaScript, the regular expression consists of two parts: the matching pattern text of the regular expression, and the modifier that matches the pattern text;Modifier:
Modifier
Description
I
Ignore case
G
Perform a global match
M
Perform multi-line matching
The
visible externally.
function, we define an entity object literal, which has two attributes, corresponding to the left and right angle brackets of the label.
returnand then an anonymous function that writes what we're going to do in this function.
We call replace the method, and the first argument places the regular expression:
/ ([^;] +);/g
The matching rule for this regular expression is: Start with "", followed by one or more than "
JS analog C # string formatting operation
/***
* * Function: string format substitution operation
***/
String.prototype.format = function () {
var args = arguments;
Return This.replace (/\{(\d+) \}/g,
function (M, i) {return
args[i];
}
JS implements the string processing function format () similar to C #:
Familiar with C # should know that th
123456 - +Test environment: Version 40.0.2214.115 mTest results:
A represents the complete substring of the match, such as:
b indicates the successful part of the match, such as: LT
c indicates the subscript of the matched complete substring, such as: 0
D indicates a test string, such as:
E for undefined
About "capturing group" in regular expressions, refers to the regular expression through () the
String.charat (POS);The Chartat method returns the character of the POS position in string./* * * Returns the character at the parameter position */ var name = "CHENQF"; Name.charat (1); //String.Concat (String ...);Constructs a new string by connecting the string to the argument./* * * for connection strings, but not
Use of the String. match () method in JavaScript
This article describes how to use the String. match () method in JavaScript. It is the basic knowledge in the JS beginners. For more information, see
This method is used to retrieve and match strings targeting regular expressions.
Syntax
?
1
The use of the String. match () method in JavaScript is described in detail, and javascriptstring
This method is used to retrieve and match strings targeting regular expressions.Syntax
String. match (param)
The following is the detailed information about the parameters:
Param: Regular Expression object
Return Value:
If the regular expression does no
Function: Split () Function: uses a specified separator to split a string and store it in an array.Example:STR = "JPG | BMP | GIF | ICO | PNG ";Arr = thestring. Split ("| ");// Arr is an array containing character values "jpg", "BMP", "GIF", "ICO", and "PNG"
Function: John () Function: combines an array into a string using the separator you selected.Example:VaR delimitedstring = myarray. Join (delimiter );
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.