kclearr,clc, A='k b a'; t=0:9;

使用MATLAB解的方程答案结果为什么是零clear allclcs0=0.99998;i0=0.00002;a=((s0*x-1)^2+2*s0*i0*x^2)^(1/2);b=atanh(s0*x-1)/a;t=[1 3 7 9 12 15 18 22 27 30 32 36 37 39 42 44 46 52];f=(a^2.*y)./((2.*s0.*x^2.*cosh(((a.*y).*t))./2-b));s=[3 2 4 1 3 4 1 7 20 9 6 10 16 29 23 47 24 12];z=0;for i=1:1:18z=z+(s(i)-f(i))^2;endp=diff(z,'x',1);q=diff(z,'y',1);[x,y]=solve('p=0','q=0');x=vpa(x,5),y=vpa(y,5)我写的一个求解一个关于SIR模型计算miu和sita的一个MATLAB程序,我已经检查了变量与数学解析式的变量的对应,但是确实不应该啊,结果始终得出是零.是不是与solve的使用有关,含有solve是解方程的最优解法吗
solve函数的语法定义主要有以下四种:solve(eq)solve(eq,var)solve(eq1,eq2,…,eqn)g = solve(eq1,eq2,…,eqn,var1,var2,…,varn)
为您推荐:
其他类似问题
扫描下载二维码matlab柱状图显示不同的颜色实现不了,我想让画出来的柱状图显示不同的颜色,不知道这段代码有什么错误,实现不了,clear allclcy=[1,2,3,4,5,4,5,9,2,4,6,7,2,3,1];x=bar(y,0.5);a=length(y);for i=1:a;& & b=[0 1 i/100];endch=get(x,'children');set(ch,'FaceVertexCData',b)
kjEF14MH04
clear&allclcy=[1,2,3,4,5,4,5,9,2,4,6,7,2,3,1];x=bar(y,0.5);a=length(y);b=[];for&i=1:a&&&&b=[b;rand(1,3)];endcolormap(b);ch=get(x,'children');fvd=get(ch,'Faces');fvcd=get(ch,'FaceVertexCData');[ys,iys]=sortrows(y',1);for&i&=&1:a&&&&row&=&iys(i);&&&&fvcd(fvd(row,:))&=&i;endset(ch,'FaceVertexCData',fvcd)
为您推荐:
其他类似问题
扫描下载二维码,下载次数:184 次
| 关键字:
DesignTimeResolveAssemblyReferencesInput.cache[5KB]
Properties
mon.csproj.user[227B]
SenBiTeSolution.DAL
DesignTimeResolveAssemblyReferencesInput.cache[6KB]
Properties
SenBiTeSolution.DBUtility
DesignTimeResolveAssemblyReferencesInput.cache[5KB]
Properties
SenBiTeSolution.Model
DesignTimeResolveAssemblyReferencesInput.cache[5KB]
Properties
SenBiTeSolution.UI
SenBiTeDB.mdb[760KB]
5-.gif[132B]
aa.jpg[70KB]
about_company.gif[1KB]
banner_bg.gif[470B]
banner_bg_01.gif[416B]
btn_bg.png[3KB]
company_About_Title.jpg[2KB]
contact_title.png[4KB]
foot_bg.gif[443B]
huiyi.gif[3KB]
ico_01.gif[62B]
line_01.gif[50B]
logo.gif[3KB]
logo_01.png[13KB]
message_title.png[3KB]
new.gif[1KB]
new_title.png[3KB]
page_bg.png[2KB]
phone.jpg[2KB]
pingfeng.jpg[4KB]
product_bg.jpg[1KB]
product_hot_bg.jpg[13KB]
product_Title.gif[2KB]
product_title.jpg[14KB]
service_title.png[3KB]
shafa.gif[2KB]
success_case.jpg[14KB]
teShe_01.jpg[30KB]
teShe_02.jpg[25KB]
teShe_03.jpg[29KB]
teShe_04.jpg[29KB]
zuoyi.gif[2KB]
5-.gif[132B]
aa.jpg[49KB]
about_company.gif[1KB]
banner_bg.gif[470B]
banner_bg_01.gif[416B]
btn_bg.png[3KB]
company_About_Title.jpg[2KB]
contact_title.png[4KB]
foot_bg.gif[443B]
huiyi.gif[3KB]
ico_01.gif[62B]
line_01.gif[50B]
logo.gif[1KB]
logo_01.png[23KB]
message_title.png[3KB]
new.gif[1KB]
new_title.png[3KB]
page_bg.png[2KB]
phone.jpg[2KB]
pingfeng.jpg[4KB]
product_bg.jpg[1KB]
product_hot_bg.jpg[13KB]
product_Title.gif[2KB]
product_title.jpg[14KB]
service_title.png[3KB]
shafa.gif[2KB]
success_case.jpg[14KB]
teShe_01.jpg[30KB]
teShe_02.jpg[25KB]
teShe_03.jpg[29KB]
teShe_04.jpg[29KB]
zuoyi.gif[2KB]
ico_03.png[165B]
ico_05.png[167B]
ico_09.png[166B]
ico_10.png[163B]
logo.jpg[8KB]
main_34.gif[1KB]
menuFoot.png[243B]
menuTitle.png[899B]
tab_bg.gif[376B]
tab_bghot.png[2KB]
top_bg.png[268B]
bg_01.png[2KB]
btn_01.png[2KB]
btn_bg_01.png[2KB]
button_01.png[2KB]
content03.png[304B]
content04.png[187B]
content06.png[360B]
content11.png[136B]
content14.png[335B]
content17.png[185B]
content18.png[338B]
del.gif[145B]
edt.gif[197B]
home.png[3KB]
Login.jpg[114KB]
DesignTimeResolveAssemblyReferencesInput.cache[129KB]
ProductImg
3.jpg[170KB]
4.jpg[170KB]
9.jpg[170KB]
6.jpg[170KB]
.jpg[309KB]
.jpg[645KB]
.jpg[165KB]
.jpg[227KB]
.jpg[236KB]
.png[37KB]
.png[35KB]
.png[36KB]
.png[39KB]
.png[38KB]
.png[18KB]
.png[31KB]
.png[33KB]
.png[14KB]
.png[12KB]
.png[13KB]
.png[13KB]
.png[13KB]
.png[34KB]
.png[23KB]
.png[23KB]
.png[21KB]
.png[31KB]
.png[32KB]
Properties
attachment
fileTypeImages
icon_chm.gif[923B]
icon_default.png[841B]
icon_doc.gif[1012B]
icon_exe.gif[949B]
icon_mp3.gif[986B]
icon_mv.gif[1001B]
icon_pdf.gif[996B]
icon_ppt.gif[1001B]
icon_psd.gif[1009B]
icon_rar.gif[1007B]
icon_txt.gif[970B]
icon_xls.gif[1005B]
background
C_0001.gif[11KB]
C_0002.gif[39KB]
C_0003.gif[3KB]
C_0004.gif[25KB]
C_0005.gif[25KB]
C_0006.gif[33KB]
C_0007.gif[30KB]
C_0008.gif[32KB]
C_0009.gif[19KB]
C_0010.gif[31KB]
C_0011.gif[31KB]
C_0012.gif[24KB]
C_0013.gif[20KB]
C_0014.gif[24KB]
C_0015.gif[7KB]
C_0016.gif[44KB]
C_0017.gif[44KB]
C_0018.gif[40KB]
C_0019.gif[25KB]
C_0020.gif[80KB]
b_0001.gif[13KB]
b_0002.gif[14KB]
b_0003.gif[5KB]
b_0004.gif[2KB]
b_0005.gif[6KB]
b_0006.gif[7KB]
b_0007.gif[5KB]
b_0008.gif[12KB]
b_0009.gif[11KB]
b_0010.gif[9KB]
b_0011.gif[14KB]
b_0012.gif[15KB]
b_0013.gif[7KB]
b_0014.gif[9KB]
b_0015.gif[1KB]
b_0016.gif[11KB]
b_0017.gif[11KB]
b_0018.gif[8KB]
b_0019.gif[17KB]
b_0020.gif[13KB]
b_0021.gif[13KB]
b_0022.gif[13KB]
b_0023.gif[6KB]
b_0024.gif[7KB]
b_0025.gif[9KB]
b_0026.gif[5KB]
b_0027.gif[9KB]
b_0028.gif[7KB]
b_0029.gif[12KB]
b_0030.gif[16KB]
b_0031.gif[10KB]
b_0032.gif[14KB]
b_0033.gif[15KB]
b_0034.gif[16KB]
b_0035.gif[15KB]
b_0036.gif[19KB]
b_0037.gif[7KB]
b_0038.gif[9KB]
b_0039.gif[3KB]
b_0040.gif[14KB]
b_0041.gif[12KB]
b_0042.gif[11KB]
b_0043.gif[4KB]
b_0044.gif[7KB]
b_0045.gif[13KB]
b_0046.gif[10KB]
b_0047.gif[19KB]
b_0048.gif[17KB]
b_0049.gif[15KB]
b_0050.gif[17KB]
b_0051.gif[15KB]
b_0052.gif[12KB]
b_0053.gif[7KB]
b_0054.gif[17KB]
b_0055.gif[12KB]
b_0056.gif[10KB]
b_0057.gif[14KB]
b_0058.gif[5KB]
b_0059.gif[4KB]
b_0060.gif[14KB]
b_0061.gif[4KB]
b_0062.gif[11KB]
b_0063.gif[13KB]
i_f_01.gif[588B]
i_f_02.gif[577B]
i_f_03.gif[572B]
i_f_04.gif[581B]
i_f_05.gif[585B]
i_f_06.gif[598B]
i_f_07.gif[596B]
i_f_08.gif[586B]
i_f_09.gif[544B]
i_f_10.gif[610B]
i_f_11.gif[646B]
i_f_12.gif[598B]
i_f_13.gif[618B]
i_f_14.gif[617B]
i_f_15.gif[628B]
i_f_16.gif[580B]
i_f_17.gif[582B]
i_f_18.gif[617B]
i_f_19.gif[606B]
i_f_20.gif[617B]
i_f_21.gif[594B]
i_f_22.gif[522B]
i_f_23.gif[529B]
i_f_24.gif[558B]
i_f_25.gif[533B]
i_f_26.gif[833B]
i_f_27.gif[834B]
i_f_28.gif[914B]
i_f_29.gif[853B]
i_f_30.gif[836B]
i_f_31.gif[874B]
i_f_32.gif[820B]
i_f_33.gif[854B]
i_f_34.gif[832B]
i_f_35.gif[889B]
i_f_36.gif[840B]
i_f_37.gif[853B]
i_f_38.gif[787B]
i_f_39.gif[1KB]
i_f_40.gif[918B]
i_f_41.gif[826B]
i_f_42.gif[1KB]
i_f_43.gif[771B]
i_f_44.gif[809B]
i_f_45.gif[1KB]
i_f_46.gif[305B]
i_f_47.gif[767B]
i_f_48.gif[808B]
i_f_49.gif[773B]
i_f_50.gif[787B]
j_0001.gif[14KB]
j_0002.gif[7KB]
j_0003.gif[7KB]
j_0004.gif[10KB]
j_0005.gif[5KB]
j_0006.gif[11KB]
j_0007.gif[10KB]
j_0008.gif[7KB]
j_0009.gif[9KB]
j_0010.gif[7KB]
j_0011.gif[14KB]
j_0012.gif[13KB]
j_0013.gif[2KB]
j_0014.gif[14KB]
j_0015.gif[11KB]
j_0016.gif[6KB]
j_0017.gif[3KB]
j_0018.gif[9KB]
j_0019.gif[12KB]
j_0020.gif[3KB]
j_0021.gif[7KB]
j_0022.gif[11KB]
j_0023.gif[10KB]
j_0024.gif[4KB]
j_0025.gif[7KB]
j_0026.gif[9KB]
j_0027.gif[4KB]
j_0028.gif[9KB]
j_0029.gif[13KB]
j_0030.gif[14KB]
j_0031.gif[5KB]
j_0032.gif[2KB]
j_0033.gif[6KB]
j_0034.gif[7KB]
j_0035.gif[5KB]
j_0036.gif[12KB]
j_0037.gif[11KB]
j_0038.gif[9KB]
j_0039.gif[14KB]
j_0040.gif[15KB]
j_0041.gif[7KB]
j_0042.gif[9KB]
j_0043.gif[11KB]
j_0044.gif[39KB]
j_0045.gif[3KB]
j_0046.gif[25KB]
j_0047.gif[25KB]
j_0048.gif[33KB]
j_0049.gif[30KB]
j_0050.gif[32KB]
j_0051.gif[19KB]
j_0052.gif[31KB]
j_0053.gif[31KB]
j_0054.gif[24KB]
j_0055.gif[20KB]
j_0056.gif[24KB]
j_0057.gif[588B]
j_0058.gif[577B]
j_0059.gif[572B]
j_0060.gif[581B]
j_0061.gif[585B]
j_0062.gif[598B]
j_0063.gif[596B]
j_0064.gif[586B]
j_0065.gif[544B]
j_0066.gif[610B]
j_0067.gif[646B]
j_0068.gif[598B]
j_0069.gif[618B]
j_0070.gif[617B]
j_0071.gif[11KB]
j_0072.gif[3KB]
j_0073.gif[6KB]
j_0074.gif[10KB]
j_0075.gif[23KB]
j_0076.gif[26KB]
j_0077.gif[30KB]
j_0078.gif[12KB]
j_0079.gif[18KB]
j_0080.gif[41KB]
j_0081.gif[51KB]
j_0082.gif[17KB]
j_0083.gif[18KB]
j_0084.gif[73KB]
w_0001.gif[11KB]
w_0002.gif[6KB]
w_0003.gif[3KB]
w_0004.gif[9KB]
w_0005.gif[12KB]
w_0006.gif[3KB]
w_0007.gif[7KB]
w_0008.gif[7KB]
w_0009.gif[4KB]
w_0010.gif[4KB]
w_0011.gif[12KB]
w_0012.gif[9KB]
w_0013.gif[4KB]
w_0014.gif[9KB]
w_0015.gif[8KB]
w_0016.gif[8KB]
w_0017.gif[3KB]
w_0018.gif[4KB]
w_0019.gif[7KB]
w_0020.gif[13KB]
w_0021.gif[6KB]
w_0022.gif[6KB]
w_0023.gif[6KB]
w_0024.gif[5KB]
w_0025.gif[4KB]
w_0026.gif[7KB]
w_0027.gif[16KB]
w_0028.gif[5KB]
w_0029.gif[9KB]
w_0030.gif[6KB]
w_0031.gif[7KB]
w_0032.gif[5KB]
w_0033.gif[3KB]
w_0034.gif[11KB]
w_0035.gif[4KB]
w_0036.gif[5KB]
w_0037.gif[6KB]
w_0038.gif[8KB]
w_0039.gif[4KB]
w_0040.gif[5KB]
w_0041.gif[11KB]
w_0042.gif[5KB]
w_0043.gif[5KB]
w_0044.gif[3KB]
w_0045.gif[4KB]
w_0046.gif[4KB]
w_0047.gif[9KB]
w_0048.gif[6KB]
w_0049.gif[6KB]
w_0050.gif[11KB]
w_0051.gif[10KB]
w_0052.gif[7KB]
t_0001.gif[14KB]
t_0002.gif[7KB]
t_0003.gif[7KB]
t_0004.gif[10KB]
t_0005.gif[5KB]
t_0006.gif[11KB]
t_0007.gif[10KB]
t_0008.gif[7KB]
t_0009.gif[9KB]
t_0010.gif[7KB]
t_0011.gif[14KB]
t_0012.gif[13KB]
t_0013.gif[2KB]
t_0014.gif[14KB]
t_0015.gif[12KB]
t_0016.gif[6KB]
t_0017.gif[3KB]
t_0018.gif[23KB]
t_0019.gif[5KB]
t_0020.gif[6KB]
t_0021.gif[17KB]
t_0022.gif[8KB]
t_0023.gif[4KB]
t_0024.gif[5KB]
t_0025.gif[12KB]
t_0026.gif[9KB]
t_0027.gif[18KB]
t_0028.gif[9KB]
t_0029.gif[14KB]
t_0030.gif[3KB]
t_0031.gif[4KB]
t_0032.gif[12KB]
t_0033.gif[28KB]
t_0034.gif[18KB]
t_0035.gif[11KB]
t_0036.gif[10KB]
t_0037.gif[16KB]
t_0038.gif[9KB]
t_0039.gif[4KB]
t_0040.gif[4KB]
y_0001.gif[8KB]
y_0002.gif[3KB]
y_0003.gif[11KB]
y_0004.gif[17KB]
y_0005.gif[3KB]
y_0006.gif[31KB]
y_0007.gif[13KB]
y_0008.gif[6KB]
y_0009.gif[26KB]
y_0010.gif[10KB]
y_0011.gif[23KB]
y_0012.gif[8KB]
y_0013.gif[5KB]
y_0014.gif[26KB]
y_0015.gif[30KB]
y_0016.gif[10KB]
y_0017.gif[12KB]
y_0018.gif[18KB]
y_0019.gif[41KB]
y_0020.gif[51KB]
y_0021.gif[17KB]
y_0022.gif[38KB]
y_0023.gif[26KB]
y_0024.gif[18KB]
y_0025.gif[19KB]
y_0026.gif[25KB]
y_0027.gif[73KB]
y_0028.gif[16KB]
y_0029.gif[28KB]
y_0030.gif[9KB]
y_0031.gif[7KB]
y_0032.gif[41KB]
y_0033.gif[8KB]
y_0034.gif[33KB]
y_0035.gif[31KB]
y_0036.gif[18KB]
y_0037.gif[7KB]
y_0038.gif[13KB]
y_0039.gif[9KB]
y_0040.gif[33KB]
0.gif[43B]
bface.gif[26KB]
cface.gif[8KB]
fface.gif[18KB]
jxface2.gif[39KB]
neweditor-tab-bg.png[216B]
tface.gif[19KB]
wface.gif[48KB]
yface.gif[27KB]
highlightcode
imageUploader.swf[61KB]
insertframe
addimg.png[628B]
brush.png[608B]
delimg.png[516B]
delimgH.png[578B]
empty.png[519B]
emptyH.png[657B]
eraser.png[42KB]
redo.png[454B]
redoH.png[536B]
scale.png[435B]
scaleH.png[330B]
size.png[775B]
undo.png[444B]
undoH.png[511B]
searchreplace
snapscreen
bg.gif[84B]
pre0.png[250B]
pre1.png[291B]
pre2.png[394B]
pre3.png[485B]
pre4.png[393B]
fClipboard_ueditor.swf[1KB]
imageUploader.swf[61KB]
addimage.png[3KB]
alldeletebtnhoverskin.png[743B]
alldeletebtnupskin.png[743B]
background.png[3KB]
button.png[4KB]
copy.png[1KB]
deletedisable.png[649B]
deleteenable.png[664B]
imglabel.png[672B]
listbackground.png[3KB]
localimage.png[3KB]
rotateleftdisable.png[719B]
rotateleftenable.png[952B]
rotaterightdisable.png[754B]
rotaterightenable.png[1007B]
upload.png[3KB]
copy.png[4KB]
imglabel.png[2KB]
localimage.png[6KB]
upload.png[6KB]
43afc01c-420a-4ca7-b07f-302b8e79edeb.jpg[76KB]
7addf-49d0-a034-c6cb2a1c44ef.jpg[76KB]
fileUp.ashx[1KB]
getContent.ashx[1KB]
getMovie.ashx[1KB]
getRemoteImage.ashx[3KB]
imageManager.ashx[1KB]
imageUp.ashx[1KB]
scrawlUp.ashx[1KB]
sparator_v.png[122B]
tablepicker
highlighted.gif[111B]
unhighlighted.gif[111B]
anchor.gif[184B]
arrow.png[1KB]
button-bg.gif[1KB]
cancelbutton.gif[1KB]
center_focus.jpg[11KB]
dialog-title-bg.png[938B]
filescan.png[4KB]
icons-all.gif[3KB]
icons.gif[14KB]
icons.png[11KB]
left.jpg[9KB]
left_focus.jpg[11KB]
lock.gif[1KB]
logo.png[11KB]
neweditor-tab-bg.png[216B]
none.jpg[9KB]
none_focus.jpg[11KB]
pagebreak.gif[54B]
right.jpg[9KB]
right_focus.jpg[11KB]
spacer.gif[43B]
toolbar_bg.png[170B]
topbottom.jpg[9KB]
topbottom_focus.jpg[11KB]
upload.png[6KB]
videologo.gif[1KB]
word.gif[1019B]
third-party
codemirror2.15
snapscreen
setup.exe[343KB]
Snapsie.dll[124KB]
UEditorSnapscreen.exe[343KB]
swfupload.swf[182KB]
swfupload_fp9.swf[13KB]
SyntaxHighlighter
source code for imgupload with flash.zip[341KB]
CHANGELOG.TXT[10KB]
Http_ImgLoad.ashx[110B]
SenBiTeSolution.UI.csproj.user[1KB]
from.gif[4KB]
SenBiTeSolution.sln[2KB]
SenBiTeSolution.suo[138KB]
最新Asp.Net源码下载.url[123B]
当前路径:SenBiTeSolution.UI/ueditor/third-party/SyntaxHighlighter/shCore.js
* SyntaxHighlighter
* /SyntaxHighlighter
* SyntaxHighlighter is donationware. If you are using it, please donate.
* /SyntaxHighlighter/donate.html
* @version
* 3.0.83 (July 02 2010)
* @copyright
* Copyright (C)
Alex Gorbatchev.
* @license
* Dual licensed under the MIT and GPL licenses.
// Begin anonymous function. This is used to contain local scope variables without polutting global scope.
// XRegExp 1.5.0
Steven Levithan
// MIT License
// Provides an augmented, extensible, cross-browser implementation of regular expressions,
// including support for additional syntax, flags, and methods
if (!XRegExp) {
// Run within an anonymous function to protect variables and avoid new globals
(function () {
//---------------------------------
Constructor
//---------------------------------
// Accepts returns a new, extended `RegExp` object. Differs from a native
// regular expression in that additional syntax and flags are supported and cross-browser
// syntax inconsistencies are ameliorated
XRegExp = function (pattern, flags) {
var output = [],
currScope = XRegExp.OUTSIDE_CLASS,
context, tokenResult, match, chr,
if (XRegExp.isRegExp(pattern)) {
if (flags !== undefined)
throw TypeError(&can't supply flags when constructing one RegExp from another&);
return clone(pattern);
// Tokens become part of the regex construction process, so protect against infinite
// recursion when an XRegExp is constructed within a token handler or trigger
if (isInsideConstructor)
throw Error(&can't call the XRegExp constructor within token definition functions&);
flags = flags || &&;
context = { // `this` object for custom tokens
hasNamedCapture: false,
captureNames: [],
hasFlag: function (flag) {return flags.indexOf(flag) & -1;},
setFlag: function (flag) {flags +=}
while (pos & pattern.length) {
// Check for custom tokens at the current position
tokenResult = runTokens(pattern, pos, currScope, context);
if (tokenResult) {
output.push(tokenResult.output);
pos += (tokenResult.match[0].length || 1);
// Check for native multicharacter metasequences (excluding character classes) at
// the current position
if (match = real.exec.call(nativeTokens[currScope], pattern.slice(pos))) {
output.push(match[0]);
pos += match[0].
chr = pattern.charAt(pos);
if (chr === &[&)
currScope = XRegExp.INSIDE_CLASS;
else if (chr === &]&)
currScope = XRegExp.OUTSIDE_CLASS;
// Advance position one character
output.push(chr);
regex = RegExp(output.join(&&), real.replace.call(flags, flagClip, &&));
regex._xregexp = {
source: pattern,
captureNames: context.hasNamedCapture ? context.captureNames : null
//---------------------------------
Public properties
//---------------------------------
XRegExp.version = &1.5.0&;
// Token scope bitflags
XRegExp.INSIDE_CLASS = 1;
XRegExp.OUTSIDE_CLASS = 2;
//---------------------------------
Private variables
//---------------------------------
var replacementToken = /\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g,
flagClip = /[^gimy]+|([\s\S])(?=[\s\S]*\1)/g, // Nonnative and duplicate flags
quantifier = /^(?:[?*+]|{\d+(?:,\d*)?})\??/,
isInsideConstructor = false,
tokens = [],
// Copy native globals for reference (&native& is an ES3 reserved keyword)
exec: RegExp.prototype.exec,
test: RegExp.prototype.test,
match: String.prototype.match,
replace: String.prototype.replace,
split: String.prototype.split
compliantExecNpcg = real.exec.call(/()??/, &&)[1] === undefined, // check `exec` handling of nonparticipating capturing groups
compliantLastIndexIncrement = function () {
var x = /^/g;
real.test.call(x, &&);
return !x.lastI
compliantLastIndexReset = function () {
var x = /x/g;
real.replace.call(&x&, x, &&);
return !x.lastI
hasNativeY = RegExp.prototype.sticky !== undefined,
nativeTokens = {};
// `nativeTokens` match native multicharacter metasequences only (including deprecated octals,
// excluding character classes)
nativeTokens[XRegExp.INSIDE_CLASS] = /^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/;
nativeTokens[XRegExp.OUTSIDE_CLASS] = /^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/;
//---------------------------------
Public methods
//---------------------------------
// Lets you extend or change XRegExp syntax and create custom flags. This is used internally by
// the XRegExp library and can be used to create XRegExp plugins. This function is intended for
// users with advanced knowledge of JavaScript's regular expression syntax and behavior. It can
// be disabled by `XRegExp.freezeTokens`
XRegExp.addToken = function (regex, handler, scope, trigger) {
tokens.push({
pattern: clone(regex, &g& + (hasNativeY ? &y& : &&)),
handler: handler,
scope: scope || XRegExp.OUTSIDE_CLASS,
trigger: trigger || null
// Accepts returns an extended `RegExp` object. If the pattern and flag
// combination has previously been cached, the cac otherwise the newly
// created regex is cached
XRegExp.cache = function (pattern, flags) {
var key = pattern + &/& + (flags || &&);
return XRegExp.cache[key] || (XRegExp.cache[key] = XRegExp(pattern, flags));
// Accepts a `RegExp` returns a copy with the `/g` flag set. The copy has a fresh
// `lastIndex` (set to zero). If you want to copy a regex without forcing the `global`
// property, use `XRegExp(regex)`. Do not use `RegExp(regex)` because it will not preserve
// special properties required for named capture
XRegExp.copyAsGlobal = function (regex) {
return clone(regex, &g&);
// A returns the string with regex metacharacters escaped. The returned string
// can safely be used at any point within a regex to match the provided literal string. Escaped
// characters are [ ] { } ( ) * + ? - . , \ ^ $ | # and whitespace
XRegExp.escape = function (str) {
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, &\\$&&);
// Accepts a string to search, regex to search with, position to start the search within the
// string (default: 0), and an optional Boolean indicating whether matches must start at-or-
// after the position or at the specified position only. This function ignores the `lastIndex`
// property of the provided regex
XRegExp.execAt = function (str, regex, pos, anchored) {
regex = clone(regex, &g& + ((anchored && hasNativeY) ? &y& : &&));
regex.lastIndex = pos = pos || 0;
var match = regex.exec(str);
if (anchored)
return (match && match.index === pos) ? match :
// Breaks the unrestorable link to XRegExp's private list of tokens, thereby preventing
// syntax and flag changes. Should be run after XRegExp and any plugins are loaded
XRegExp.freezeTokens = function () {
XRegExp.addToken = function () {
throw Error(&can't run addToken after freezeTokens&);
// A returns a Boolean indicating whether the argument is a `RegExp` object.
// Note that this is also `true` for regex literals and regexes created by the `XRegExp`
// constructor. This works correctly for variables created in another frame, when `instanceof`
// and `constructor` checks would fail to work as intended
XRegExp.isRegExp = function (o) {
return Object.prototype.toString.call(o) === &[object RegExp]&;
// Executes `callback` once per match within `str`. Provides a simpler and cleaner way to
// iterate over regex matches compared to the traditional approaches of subverting
// `String.prototype.replace` or repeatedly calling `exec` within a `while` loop
XRegExp.iterate = function (str, origRegex, callback, context) {
var regex = clone(origRegex, &g&),
while (match = regex.exec(str)) {
callback.call(context, match, ++i, str, regex);
if (regex.lastIndex === match.index)
regex.lastIndex++;
if (origRegex.global)
origRegex.lastIndex = 0;
// Accepts a string and returns the result of using each successive regex
// to search within the matches of the previous regex. The array of regexes can also contain
// objects with `regex` and `backref` properties, in which case the named or numbered back-
// references specified are passed forward to the next regex or returned. E.g.:
// var xregexpImgFileNames = XRegExp.matchChain(html, [
{regex: /&img\b([^&]+)&/i, backref: 1}, // &img& tag attributes
{regex: XRegExp('(?ix) \\s src=& (?&src& [^&]+ )'), backref: &src&}, // src attribute values
{regex: XRegExp(&^http://xregexp\\.com(/[^#?]+)&, &i&), backref: 1}, //
/[^\/]+$/ // filenames (strip directory paths)
XRegExp.matchChain = function (str, chain) {
return function recurseChain (values, level) {
var item = chain[level].regex ? chain[level] : {regex: chain[level]},
regex = clone(item.regex, &g&),
matches = [],
for (i = 0; i & values. i++) {
XRegExp.iterate(values[i], regex, function (match) {
matches.push(item.backref ? (match[item.backref] || &&) : match[0]);
return ((level === chain.length - 1) || !matches.length) ?
matches : recurseChain(matches, level + 1);
}([str], 0);
//---------------------------------
New RegExp prototype methods
//---------------------------------
// Accepts a context object returns the result of calling `exec` with the
// first value in the arguments array. the context is ignored but is accepted for congruity
// with `Function.prototype.apply`
RegExp.prototype.apply = function (context, args) {
return this.exec(args[0]);
// Accepts a conte returns the result of calling `exec` with the provided
// string. the context is ignored but is accepted for congruity with `Function.prototype.call`
RegExp.prototype.call = function (context, str) {
return this.exec(str);
//---------------------------------
Overriden native methods
//---------------------------------
// Adds named capture support (with backreferences returned as `result.name`), and fixes two
// cross-browser issues per ES3:
// - Captured values for nonparticipating capturing groups should be returned as `undefined`,
rather than the empty string.
// - `lastIndex` should not be incremented after zero-length matches.
RegExp.prototype.exec = function (str) {
var match = real.exec.apply(this, arguments),
if (match) {
// Fix browsers whose `exec` methods don't consistently return `undefined` for
// nonparticipating capturing groups
if (!compliantExecNpcg && match.length & 1 && indexOf(match, &&) & -1) {
r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), &g&, &&));
// Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
// matching due to characters outside the match
//修复跟jquery冲突的问题
if (str) str += '';
real.replace.call(str.toString().slice(match.index), r2, function () {
for (var i = 1; i & arguments.length - 2; i++) {
if (arguments[i] === undefined)
match[i] =
// Attach named capture properties
if (this._xregexp && this._xregexp.captureNames) {
for (var i = 1; i & match. i++) {
name = this._xregexp.captureNames[i - 1];
match[name] = match[i];
// Fix browsers that increment `lastIndex` after zero-length matches
if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex & match.index))
this.lastIndex--;
// Don't override `test` if it won't change anything
if (!compliantLastIndexIncrement) {
// Fix browser bug in native method
RegExp.prototype.test = function (str) {
// Use the native `exec` to skip some processing overhead, even though the overriden
// `exec` would take care of the `lastIndex` fix
var match = real.exec.call(this, str);
// Fix browsers that increment `lastIndex` after zero-length matches
if (match && this.global && !match[0].length && (this.lastIndex & match.index))
this.lastIndex--;
// Adds named capture support and fixes browser bugs in native method
String.prototype.match = function (regex) {
if (!XRegExp.isRegExp(regex))
regex = RegExp(regex); // Native `RegExp`
if (regex.global) {
var result = real.match.apply(this, arguments);
regex.lastIndex = 0; // Fix IE bug
return regex.exec(this); // Run the altered `exec`
// Adds support for `${n}` tokens for named and numbered backreferences in replacement text,
// and provides named backreferences to replacement functions as `arguments[0].name`. Also
// fixes cross-browser differences in replacement text syntax when performing a replacement
// using a nonregex search value, and the value of replacement regexes' `lastIndex` property
// during replacement iterations. Note that this doesn't support SpiderMonkey's proprietary
// third (`flags`) parameter
String.prototype.replace = function (search, replacement) {
var isRegex = XRegExp.isRegExp(search),
captureNames, result,
// There are many combinations of search/replacement types/values and browser bugs that
// preclude passing to native `replace`, so just keep this check relatively simple
if (isRegex && typeof replacement.valueOf() === &string& && replacement.indexOf(&${&) === -1 && compliantLastIndexReset)
return real.replace.apply(this, arguments);
if (!isRegex)
search = search + &&; // Type conversion
else if (search._xregexp)
captureNames = search._xregexp.captureN // Array or `null`
if (typeof replacement === &function&) {
result = real.replace.call(this, search, function () {
if (captureNames) {
// Change the `arguments[0]` string primitive to a String object which can store properties
arguments[0] = new String(arguments[0]);
// Store named backreferences on `arguments[0]`
for (var i = 0; i & captureNames. i++) {
if (captureNames[i])
arguments[0][captureNames[i]] = arguments[i + 1];
// Update `lastIndex` before calling `replacement`
if (isRegex && search.global)
search.lastIndex = arguments[arguments.length - 2] + arguments[0].
return replacement.apply(null, arguments);
str = this + &&; // Type conversion, so `args[args.length - 1]` will be a string (given nonstring `this`)
result = real.replace.call(str, search, function () {
var args = // Keep this function's `arguments` available through closure
return real.replace.call(replacement, replacementToken, function ($0, $1, $2) {
// Numbered backreference (without delimiters) or special variable
switch ($1) {
case &$&: return &$&;
case &&&: return args[0];
case &`&: return args[args.length - 1].slice(0, args[args.length - 2]);
case &'&: return args[args.length - 1].slice(args[args.length - 2] + args[0].length);
// Numbered backreference
// What does &$10& mean?
// - Backreference 10, if 10 or more capturing groups exist
// - Backreference 1 followed by &0&, if 1-9 capturing groups exist
// - Otherwise, it's the string &$10&
// Also note:
// - Backreferences cannot be more than two digits (enforced by `replacementToken`)
// - &$01& is equivalent to &$1& if a capturing group exists, otherwise it's the string &$01&
// - There is no &$0& token (&$&& is the entire match)
var literalNumbers = &&;
$1 = +$1; // T drop leading zero
if (!$1) // `$1` was &0& or &00&
return $0;
while ($1 & args.length - 3) {
literalNumbers = String.prototype.slice.call($1, -1) + literalN
$1 = Math.floor($1 / 10); // Drop the last digit
return ($1 ? args[$1] || && : &$&) + literalN
// Named backreference or delimited numbered backreference
// What does &${n}& mean?
// - Backreference to numbered capture n. Two differences from &$n&:
- n can be more than two digits
- Backreference 0 is allowed, and is the entire match
// - Backreference to named capture n, if it exists and is not a number overridden by numbered capture
// - Otherwise, it's the string &${n}&
var n = +$2; // T drop leading zeros
if (n &= args.length - 3)
return args[n];
n = captureNames ? indexOf(captureNames, $2) : -1;
return n & -1 ? args[n + 1] : $0;
if (isRegex && search.global)
search.lastIndex = 0; // Fix IE bug
// A consistent cross-browser, ES3 compliant `split`
String.prototype.split = function (s /* separator */, limit) {
// If separator `s` is not a regex, use the native `split`
if (!XRegExp.isRegExp(s))
return real.split.apply(this, arguments);
var str = this + &&, // Type conversion
output = [],
lastLastIndex = 0,
match, lastL
// Behavior for `limit`: if it's...
// - `undefined`: No limit
// - `NaN` or zero: Return an empty array
// - A positive number: Use `Math.floor(limit)`
// - A negative number: No limit
// - Other: Type-convert, then use the above rules
if (limit === undefined || +limit & 0) {
limit = Math.floor(+limit);
if (!limit)
return [];
// This is required if not `s.global`, and it avoids needing to set `s.lastIndex` to zero
// and restore it to its original value when we're done using the regex
s = XRegExp.copyAsGlobal(s);
while (match = s.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.)
if (s.lastIndex & lastLastIndex) {
output.push(str.slice(lastLastIndex, match.index));
if (match.length & 1 && match.index & str.length)
Array.prototype.push.apply(output, match.slice(1));
lastLength = match[0].
lastLastIndex = s.lastI
if (output.length &= limit)
if (s.lastIndex === match.index)
s.lastIndex++;
if (lastLastIndex === str.length) {
if (!real.test.call(s, &&) || lastLength)
output.push(&&);
output.push(str.slice(lastLastIndex));
return output.length & limit ? output.slice(0, limit) :
//---------------------------------
Private helper functions
//---------------------------------
// Supporting function for `XRegExp`, `XRegExp.copyAsGlobal`, etc. Returns a copy of a `RegExp`
// instance with a fresh `lastIndex` (set to zero), preserving properties required for named
// capture. Also allows adding new flags in the process of copying the regex
function clone (regex, additionalFlags) {
if (!XRegExp.isRegExp(regex))
throw TypeError(&type RegExp expected&);
var x = regex._
regex = XRegExp(regex.source, getNativeFlags(regex) + (additionalFlags || &&));
regex._xregexp = {
source: x.source,
captureNames: x.captureNames ? x.captureNames.slice(0) : null
function getNativeFlags (regex) {
return (regex.global
? &g& : &&) +
(regex.ignoreCase ? &i& : &&) +
(regex.multiline
? &m& : &&) +
(regex.extended
? &x& : &&) + // Proposed for ES4; included in AS3
(regex.sticky
? &y& : &&);
function runTokens (pattern, index, scope, context) {
var i = tokens.length,
result, match,
// Protect against constructing XRegExps within token handler and trigger functions
isInsideConstructor =
// Must reset `isInsideConstructor`, even if a `trigger` or `handler` throws
while (i--) { // Run in reverse order
t = tokens[i];
if ((scope & t.scope) && (!t.trigger || t.trigger.call(context))) {
t.pattern.lastIndex =
match = t.pattern.exec(pattern); // Running the altered `exec` here allows use of named backreferences, etc.
if (match && match.index === index) {
result = {
output: t.handler.call(context, match, scope),
match: match
} catch (err) {
} finally {
isInsideConstructor =
function indexOf (array, item, from) {
if (Array.prototype.indexOf) // Use the native array method if available
return array.indexOf(item, from);
for (var i = from || 0; i & array. i++) {
if (array[i] === item)
return -1;
//---------------------------------
Built-in tokens
//---------------------------------
// Augment XRegExp's regular expression syntax and flags. Note that when adding tokens, the
// third (`scope`) argument defaults to `XRegExp.OUTSIDE_CLASS`
// Comment pattern: (?# )
XRegExp.addToken(
/\(\?#[^)]*\)/,
function (match) {
// Keep tokens separated unless the following token is a quantifier
return real.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? && : &(?:)&;
// Capturing group (match the opening parenthesis only).
// Required for support of named capturing groups
XRegExp.addToken(
/\((?!\?)/,
function () {
this.captureNames.push(null);
return &(&;
// Named capturing group (match the opening delimiter only): (?&name&
XRegExp.addToken(
/\(\?&([$\w]+)&/,
function (match) {
this.captureNames.push(match[1]);
this.hasNamedCapture =
return &(&;
// Named backreference: \k&name&
XRegExp.addToken(
/\\k&([\w$]+)&/,
function (match) {
var index = indexOf(this.captureNames, match[1]);
// Keep backreferences separate from subsequent literal numbers. Preserve back-
// references to named groups that are undefined at this point as literal strings
return index & -1 ?
&\\& + (index + 1) + (isNaN(match.input.charAt(match.index + match[0].length)) ? && : &(?:)&) :
// Empty character class: [] or [^]
XRegExp.addToken(
function (match) {
// For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S].
// (?!) should work like \b\B, but is unreliable in Firefox
return match[0] === &[]& ? &\\b\\B& : &[\\s\\S]&;
// Mode modifier at the start of the pattern only, with any combination of flags imsx: (?imsx)
// Does not support x(?i), (?-i), (?i-m), (?i: ), (?i)(?m), etc.
XRegExp.addToken(
/^\(\?([imsx]+)\)/,
function (match) {
this.setFlag(match[1])...

我要回帖

更多关于 matlab clc clear all 的文章

 

随机推荐