首先,我会说我在这里看到很多例子和谷歌搜索,但没有发现匹配所有条件我正在寻找一些匹配前三名不低于一些中间.请告诉我如何将所有这些放在一个地方.
(xxx)xxxxxxx
(xxx) xxxxxxx
(xxx)xxx-xxxx
(xxx) xxx-xxxx
xxxxxxxxxx
xxx-xxx-xxxxx
Run Code Online (Sandbox Code Playgroud)
用作:
const string MatchPhonePattern =
@"\(?\d{3}\)?-? *\d{3}-? *-?\d{4}";
Regex rx = new Regex(MatchPhonePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
// Find matches.
MatchCollection matches = rx.Matches(text);
// Report the number of matches found.
int noOfMatches = matches.Count;
// Report on each match.
foreach (Match match in matches)
{
tempPhoneNumbers= match.Value.ToString(); ;
}
Run Code Online (Sandbox Code Playgroud)
样本输出:
3087774825
(281)388-0388
(281)388-0300
(979) 778-0978
(281)934-2479
(281)934-2447
(979)826-3273
(979)826-3255
1334714149
(281)356-2530
(281)356-5264
(936)825-2081
(832)595-9500
(832)595-9501
281-342-2452
1334431660
Run Code Online (Sandbox Code Playgroud) 我有一个类来处理会话变量.这是附件样本:
namespace General
{
public class Session
{
public Session()
{
}
public static string UserID
{
get { return HttpContext.Current.Session["UserID"] as string ?? String.Empty; }
set { HttpContext.Current.Session["UserID"] = value; }
}
public static string departFlightID
{
get { return HttpContext.Current.Session["departFlightID"] as string ?? String.Empty; }
set { HttpContext.Current.Session["departFlightID"] = value; }
}
public static string returnFlightID
{
get { return HttpContext.Current.Session["returnFlightID"] as string ?? String.Empty; }
set { HttpContext.Current.Session["returnFlightID"] = value; }
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在在某些时候我存储flightID在: …
我想在我的excel VBA代码中更改这些行更快,而不是循环遍历所有行,我确实看到了示例但无法理解它们,因为我不是VBA用户.
当我在样本中使用代码(谷歌,这个网站)时,我没有看到我想要的正确需求,我想搜索列A,如果找到的值返回搜索值旁边的列B中的值,否则返回空.
我使用的大多数代码在未找到时返回错误以及其他一些神秘行为.
我目前要搜索的代码是:
Dim k As Integer
For k = 2 To sheet2Counter - 1
Dim tmp As String
tmp = ActiveSheet.Range("A" & k).Value
If tmp = tmpstr Then
tmp = ActiveSheet.Range("B" & k).Value
tmp = Replace(tmp, "Q", "A")
mainstringtopaste = mainstringtopaste + tmp + ","
Exit For
End If
Next k
Run Code Online (Sandbox Code Playgroud)
如果这是一种更好的方式或任何代替它的代码更快,请告诉我.
要搜索的工作表中的列如下:
ColumnA ColumnB
trees leaves
oranges fruits
pineapple fruits
leaves trees
Run Code Online (Sandbox Code Playgroud)
所以我的上面的代码应该搜索树,并返回叶子...
谢谢
我在下面使用此查询来验证用户.
此查询在SQL Server和我的Asp.Net网站中完美运行.
SELECT *
FROM AdminUsers
WHERE username = 'admin' COLLATE SQL_Latin1_General_CP1_CS_AS
AND Password = (SELECT HASHBYTES('SHA1', 'admin123'))
Run Code Online (Sandbox Code Playgroud)
但是,当我把它放在Asp.net/ C#代码中时:
dbManager.Command.CommandText = @"SELECT * FROM AdminUsers
WHERE username= @UserName COLLATE SQL_Latin1_General_CP1_CS_AS AND
Password = (SELECT HASHBYTES('SHA1', @Password))";
dbManager.Command.Parameters.AddWithValue("@userName", username);
dbManager.Command.Parameters.AddWithValue("@Password", password);
reader = dbManager.GetDataReader();
if (reader.Read() == true)
{ //USER VALIDATED }
Run Code Online (Sandbox Code Playgroud)
这不匹配所以不确定如何分配密码参数使它工作,只是为了确认输入的密码是正确的.和Password数据类型在SQL Server表VarBinary.
有什么建议?
我使用webbrowser控件打开一个网站,然后将cookie保存在cookieContainer中,稍后使用HTTPwebrequest处理前向浏览页面等.
问题出现了,当我进行搜索并返回100页时,在第一页上,它保存了一个名为ABC的cookie,我将其添加到cookiecontainer并移至下一页,在第二页上再次使用相同的Cookie命名: ABC有一些价值,但现在我在cookiecontainer中有两个相同的cookie,当我移动到下一页时,它不起作用,因为它采取了第一个混乱的东西.
怎么解决这个?
HttpWEBREQUEST功能:
public string getHtmlCookies(string url)
{
string responseData = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = "*/*";
request.AllowAutoRedirect = true;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
request.Timeout = 30000;
request.Method = "GET";
request.CookieContainer = yummycookies;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
foreach (Cookie cookie in response.Cookies)
{
string name = string.Empty;
name = cookie.Name;
string value = cookie.Value;
string path = "/";
string domain = …Run Code Online (Sandbox Code Playgroud) c# cookies httpwebrequest httpwebresponse visual-studio-2010
我是Excel VBA的新手,并编写了Vba代码来循环遍历单元格并获取它们的值.之后进行一些处理,如果匹配某个条件,则将它们附加到带换行符的列表中.执行此操作直到完成所有行.这完全正常,最终结果如下图所示:

问题是我希望格式看起来整洁,所以有一种方法,文本之间的差距在所有行上是相同的,所以它看起来很整洁.我添加行的方式是:
Dim tmpLine
tmpLine = line & " " & dateVal
mainMessage = mainMessage & tmpLine & vbNewLine
Run Code Online (Sandbox Code Playgroud)
不确定它是否完美,但这就是我所知道的......
我试图避免页面上的js警报,因为它打破了流程,浏览器卡在该页面上,直到单击弹出窗口.
我添加了Class,如示例所示:
public class JsDialogHandler : IJsDialogHandler
{
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
{
return true;
}
public bool OnJSBeforeUnload(IWebBrowser browserControl, IBrowser browser, string message, bool isReload, IJsDialogCallback callback)
{
return true;
}
public void OnResetDialogState(IWebBrowser browserControl, IBrowser browser)
{
}
public void OnDialogClosed(IWebBrowser browserControl, IBrowser browser)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我分配给Chromium浏览器:
CefSharp.Cef.Initialize(new CefSharp.CefSettings());
browser = new CefSharp.WinForms.ChromiumWebBrowser(CustomLinks[0].ToString());
JsDialogHandler jss = new JsDialogHandler();
browser.JsDialogHandler = jss;
Run Code Online (Sandbox Code Playgroud)
事情是当警报应该显示它确实运行 …
我正在使用铬浏览器来自动执行某项任务.
基本上我想加载图片,我必须在网页上点击"添加图片"锚标记.
所以我不能直接点击它不知道为什么当其他工作相同的代码.但我已设法将重点放在该锚标签上,但发送:
KeyEvent k = new KeyEvent();
k.WindowsKeyCode = 9; // TAB KEY
browser.GetBrowser().GetHost().SendKeyEvent(k);
//browser = ChromiumWebBrowser browser;
Run Code Online (Sandbox Code Playgroud)
上面的工作完全正常,因为我看到它正确的锚标签.
现在我做:
KeyEvent k = new KeyEvent();
k.WindowsKeyCode = 13; //ENTER KEY
browser.GetBrowser().GetHost().SendKeyEvent(k);
Run Code Online (Sandbox Code Playgroud)
要模拟输入密钥,但是没有任何反应,但是如果我在关键字上手动按"Enter"它就可以正常工作,那么为什么上述内容与我点击"输入密钥"的行为不一样
有什么建议.
我的SQL Server数据库中有这一行:
Province City LocationText
-------------------------------------------------------------------------------
?stanbul ?stanbul Sabiha Gökçen Havaliman? İstanbul Sabiha Gökçen Airport
Run Code Online (Sandbox Code Playgroud)
我在上面的查询中复制并粘贴上面的城市名称作为测试:
select *
from Locations
where City ='?stanbul Sabiha Gökçen Havaliman?'
Run Code Online (Sandbox Code Playgroud)
但查询返回No Result Found.我在这里错过了什么?
我正在尝试连接到 ICloud 日历并解析事件,如果我使用公共日历 url 并且工作正常,我可以做到这一点。但是,这样做我无法更新我需要连接的事件CalDav。
我很挣扎,因为这里的大多数示例都返回 404 Not Found。
任何人都可以指导我 C# 中的“ICloud Caldav 连接获取日历”示例或工作示例。
请记住,对于上述内容,我将仅拥有Username和Password帐户,因此只要我必须加载日历列表即可。