我想验证一个URL并显示消息.以下是我的代码:
$("#pageUrl").keydown(function(){
$(".status").show();
var url = $("#pageUrl").val();
if(isValidURL(url)){
$.ajax({
type: "POST",
url: "demo.php",
data: "pageUrl="+ url,
success: function(msg){
if(msg == 1 ){
$(".status").html('<img src="images/success.gif"/><span><strong>SiteID:</strong>12345678901234456</span>');
}else{
$(".status").html('<img src="images/failure.gif"/>');
}
}
});
}else{
$(".status").html('<img src="images/failure.gif"/>');
}
});
function isValidURL(url){
var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if(RegExp.test(url)){
return true;
}else{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,即使输入正确的URL直到它与正则表达式匹配,它也会显示错误消息,即使URL类似,它也会返回true "http://wwww".
我感谢你的建议.
我公司在Surround SCM中拥有大量代码库,几年前从SourceSafe迁移过来.我们正在寻求更适合我们需求的东西,但是从Surround获取我们的历史证明是一项挑战.
谷歌搜索git导入器,我找到了一个关于自定义导入器的好教程.似乎也支持svn,perforce和许多其他人,但没有Surround.
只拍一张快照并开始一个新的git repo会更好吗?或者是否值得编写脚本以获得15年以上的代码历史记录?
为什么我无法访问基类A是B类初始化列表中的成员?
class A
{
public:
explicit A(int a1):a(a1)
{
}
explicit A()
{
}
public:
int a;
public:
virtual int GetA()
{
return a;
}
};
class B : public A
{
public:
explicit B(int a1):a(a1) // wrong!, I have to write a = a1 in {}. or use A(a1)
{
}
int GetA()
{
return a+1;
}
};
class C : public A
{
public:
explicit C(int a1):a(a1)
{
}
int GetA()
{
return a-1;
}
};
Run Code Online (Sandbox Code Playgroud) 我的同事声称对于对象类型,preincrement比post增量更有效
例如
std::vector<std::string> vec;
... insert a whole bunch of strings into vec ...
// iterate over and do stuff with vec. Is this more efficient than the next
// loop?
std::vector<std::string>::iterator it;
for (it = vec.begin(); it != vec.end(); ++it){
}
// iterate over and do stuff with vec. Is this less efficient than the previous loop?
std::vector<std::string>::iterator it;
for (it = vec.begin(); it != vec.end(); it++){
}
Run Code Online (Sandbox Code Playgroud) 在我的Java SWT应用程序中,我正在托管第三方ActiveX控件.我正在使用OleClientSite来做到这一点.
// Ah, this works. :-)
OleAutomation comObject = new OleAutomation(...);
Run Code Online (Sandbox Code Playgroud)
我想从Java调用2个简单的函数.以下是COM函数定义:
[id(5)]
void easyFoo([in] int blah);
[id(20)]
void problemFoo([in] VARIANT floatArray);
Run Code Online (Sandbox Code Playgroud)
容易,对吗?这是我的假装代码:
// Ah, this works. :-)
OleAutomation comObject = new OleAutomation("Some3rdPartyControlHere");
// Call easyFoo(42). This works. :-)
int easyFooId = 5;
comObject.invoke(easyFooId, new Variant[] { new Variant(42) });
// Call problemFoo(new float[] { 4.2, 7.0 }). This doesn't work. :-(
int problemFooId = 20;
comObject.invoke(problemFooId, [ACK! What goes here?]);
Run Code Online (Sandbox Code Playgroud)
问题出在最后一行:如何将float数组传递给第三方COM对象?救命!
我最近学会了使用Zend Framework.我做了一个简单的CRUD应用程序.但是现在我想使用现有的数据库来处理更复杂的应用程序,我想知道如何在模型中调用存储过程,如何发送参数,如何读取结果并将它们存储在PHP中的数组中.请.我感谢任何帮助:)
这是我面临的一个令人讨厌的问题.如果它有一个简单的解决方案,那就不会感到惊讶.
我有2个批处理文件,我必须转换为powershell脚本.
file1.bat
---------
echo %1
echo %2
echo %3
file2.bat %*
file2.bat
--------
echo %1
echo %2
echo %3
Run Code Online (Sandbox Code Playgroud)
在命令行上,我调用此作为C:> file1.bat一二三我看到的输出是预期的一二三一二三
(这是粗略的代码示例)
当我转换为Powershell时,我有
file1.ps1
---------
Write-Host "args[0] " $args[0]
Write-Host "args[1] " $args[1]
Write-Host "args[2] " $args[2]
. ./file2.ps1 $args
file2.ps1
---------
Write-Host "args[0] " $args[0]
Write-Host "args[1] " $args[1]
Write-Host "args[2] " $args[2]
When I invoke this on powershell command line, I get
$> & file1.ps1 one two three
args[0] one
args[1] two
args[2] three
args[0] one two …Run Code Online (Sandbox Code Playgroud) 可能重复:
如何将String转换为Int?
嗨,
我有以下问题将字符串转换为整数:
string str = line.Substring(0,1);
//This picks an integer at offset 0 from string 'line'
Run Code Online (Sandbox Code Playgroud)
所以现在string str包含一个整数.我正在做以下事情:
int i = Convert.ToInt32(str);
Run Code Online (Sandbox Code Playgroud)
如果我写下面的语句,我应该打印一个整数吗?
Console.WriteLine(i);
Run Code Online (Sandbox Code Playgroud)
它编译时没有任何错误,但在运行时出现以下错误:
mscorlib.dll中发生了未处理的"System.FormatException"类型异常
附加信息:输入字符串的格式不正确.
有什么帮助吗?
我有Multi Line TextBox(C#2.0).我想显示一些数据如下.
"Contact Person : " + string1 + Environment.NewLine
"Sales Man : " + string2 + Environment.NewLine
"Credit Limit : " + string3 + Environment.NewLine
"Due days : " + string4 + Environment.NewLine
Run Code Online (Sandbox Code Playgroud)
但是此代码显示为
Contact Person : Person1
Sales Man : salesman1
Credit Limit : 50000.00
Due days : 20
Run Code Online (Sandbox Code Playgroud)
我的问题是我无法对齐文本.我的预期出局,
Contact Person : Person1
Sales Man : salesman1
Credit Limit : 50000.00
Due days : 20
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我只是想重载一个+运算符,我得到这个编译器警告
reference to local variable 'tmp' returned
Run Code Online (Sandbox Code Playgroud)
这是重载的代码
const Int& Int::operator+(const Int& p) const
{
Int tmp = value + p.value;
return tmp;
}
Run Code Online (Sandbox Code Playgroud)
这是班级
class Int{
int value;
public:
Int() {} // default constructor
Int(int v) : value(v) {}
Int& operator=(const Int&);
const Int& operator+(const Int&) const;
};
Run Code Online (Sandbox Code Playgroud) c++ ×3
c# ×2
activex ×1
alignment ×1
arguments ×1
com-interop ×1
command-line ×1
git ×1
java ×1
javascript ×1
jquery ×1
nested ×1
ole ×1
performance ×1
powershell ×1
string ×1
surroundscm ×1
swt ×1
textbox ×1
url ×1
validation ×1