Home > Web Front-end > JS Tutorial > asp word segmentation implementation code_javascript skills

asp word segmentation implementation code_javascript skills

WBOY
Release: 2016-05-16 19:13:11
Original
1157 people have browsed it

a="Japan is a province of China | Our beautiful Zhangjiajie in China!"
b="China, us, Zhangjiajie, Japan, the United States, Apple"
b=split(b,"," )
a=split(a,"|")
for k=0 to ubound(a)
s=""
n=""
for i=0 to ubound( b)
if instr(a(k),b(i))>0 then
s=s & instr(a(k),b(i)) & "," &instr(a(k) ,b(i)) len(b(i)) & ","
end if
next
s=left(s,len(s)-1)
if left(s, len(s)-1)len(a(k)) then s=s&","&len(a(k)) 1
s=sort(split(s,","))
for i=0 to ubound(s)-1
n=n&mid(a(k),s(i),s(i 1)-s(i))& "|"
next
response.write n & "
"
next

function sort(ary)
ck=true
do Until ck = false
ck=false
For f = 0 to UBound(ary) -1
if clng(ary(f))>clng(ary(f 1)) then
v1=clng(ary(f))
v2=clng( ary(f 1))
ary(f)=v2
ary(f 1)=v1
ck=true
end if
next
loop
sort=ary
end function
%>


Run result

Japan| is a province of| ! |

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template