js determines the function implementation method of the largest substring of two strings
As shown below:
<!DOCTYPE html> <html> <head> <title></title> </head> <script type="text/javascript"> function search(str1,str2) { var i=j=k=a=jk=kk=0; var m=; var n=; var index=0; var maxlen=0; var str=""; var flag=0; for (i=0;i<n;i++) { k=i; for (j=0;j<m;j++) { a = 0; flag = 0; jk=j; kk=k; while(jk<=m&&str1[kk]==str2[jk]) { kk++;jk++;a++; flag = 1; } if(flag==1) { if(a>maxlen) { maxlen = a; index = jk-a;//The first item of matching} } } } for(;maxlen>0;maxlen--) { str+=str2[index++]; } return str; } alert(search("kssd","ssdfa")); </script> <body> <div>11</div> </body> </html>
The above is the entire content of the function implementation method for determining the largest substring of two strings brought to you by the editor. I hope everyone supports me~
Related Articles
Steps to use route guards in nuxt
This article mainly introduces the methods and steps of using route guards in nuxt. The example code is introduced in this article in detail, which has certain reference learning value for everyone's learning or work. Friends who need it, please learn with the editor below.2019-01-01Internet Explorer cannot open the Internet site error under IE6
Recently, "Internet Explorer cannot open the Internet site" error often occurs under IE6.2010-06-06Solution to the problem of pull-down white screen shaking in WeChat applet iOS
This article mainly introduces the solution to the problem of pull-down white screen shaking of WeChat applet iOS. The example code is introduced in this article in detail, which has certain reference value for everyone's study or work. Friends who need it can refer to it.2019-10-10Native js realizes cute candy digital time effects
This article mainly introduces the example code for native JS to implement cute candy digital time special effects, with effect display and code demonstration. It has certain reference value, let's take a look with the editor below2016-12-123 solutions to access external variables by subfunctions in JavaScript
Any variable defined in a function can be considered private variables because these variables cannot be accessed outside the function. This article mainly introduces three solutions to access external variables by sub-functions in JavaScript. Friends who need it can refer to it.2021-06-06Detailed explanation of common type judgment methods and differences in JavaScript
In JavaScript, we often need to judge the types of data in order to perform corresponding processing. This article will introduce common type judgment methods in JavaScript, including typeof, instanceof, () and (), and will explain the differences between them in detail. Friends who need it can refer to it.2023-11-11Analysis of the usage method of bootstrap button plug-in (Button)
This article mainly analyzes the use of the bootstrap button plug-in Button in detail, which has certain reference value. Interested friends can refer to it.2017-01-01JavaScript implements the lower right corner of the blog park page to return to the top button
This article mainly introduces the idea and source code of using javascript to implement the button back to the top in the lower right corner of the blog park page. It is very good. I recommend it to friends here2015-02-02Example of usage of loading component display loading animation of WeChat applet [with source code download]
This article mainly introduces the usage of loading component display and loading animation of WeChat applets. It analyzes the related event operation and attribute setting techniques of loading component display and loading animation in combination with examples. It also comes with source code for readers to download and reference. Friends who need it can refer to it.2017-12-12A brief analysis of scope and scope chain in JavaScript
This article mainly introduces the analysis of scope and scope chains in JavaScript. It is well organized and easy to understand. It is recommended to friends here. Friends in need can refer to it.2016-12-12