|
I'm busy parsing record layout templates, and I need to determine if a field is quoted or not. I'm try to use a RegEx, and so far I have ['\"].*['\"] to match either ' or " followed by zero or more chars, followed by either ' or "
My question is, how do I check that the closing quote mark matches the opening one?
|
|
|
|
|
You would need to make the .* non-greedy by adding a ?, like so:
['"].*?['"]
But this would match: "This has differing quotes'
So you would need to break it out to separate items:
(?:["].*?["]|['].*?['])
Or you could use a back-reference like so:
(?<1>['"]).*?\1
Basically, \1 traslate into what ever was captured by the first parenthesis.
If you need to provide an escape for quotes, so you can have a double quote inside double-quotes (e.g. "This is a \" test"), then you would need to do this:
(?<1>['"])(?:\\\1|.)*?\1
In this one, we want to check for the escaped quote in the "content".
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thank you Tom!
That's more than I needed, indeed I ended up using StartsWith() and EndsWith() to get the thing out, in case the boss asks to see it, but I'll be sure to revisit with your explanation and suggestions.
BTW, what does "non-greedy" signify?
|
|
|
|
|
Let's say you have the regex: ".*"
Then in the string: "One", "Two"
It would be greedy, meaning it would match " with the first quote then One", "Two with the .* and finally " with the last quote.
If you change the regex to: ".*?"
Then the .* portion would be non-greedy, meaning it would match the first " with the first quote then One with the .*? and finally " with the last quote. And you would get a second match (if you called GetMatches over GetMatch), which would match the "Two" portion.
Does that make sense?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Yes, thank you. I've gotten this before, but only during the 'heat of the moment' Yours is a fine example that explains it permanently to me.
|
|
|
|
|
I use the following code to login to a crystal report based arround an ms access database
<add key="AccessDB" value="d:\goldmine\orielgold\Goldmine.mdb">
ConnectionInfo crInfo = new ConnectionInfo();
crInfo.DatabaseName = appSettings.Settings["AccessDB"].Value;
crInfo.ServerName = appSettings.Settings["AccessDB"].Value;
crInfo.UserID = "";
crInfo.Password = "";
I need to do this now to a secured version. I have modified the above code to
ConnectionInfo crInfo = new ConnectionInfo();
crInfo.DatabaseName = appSettings.Settings["AccessDB"].Value;
crInfo.ServerName = appSettings.Settings["AccessDB"].Value;
crInfo.UserID = "Goldmine";
crInfo.Password = "orielgold";
BUT how do I specify the location/path/name of the system.mdw file?
In previous version there was a .add property but this does not appear in VS2005/CR XI R2 system.
Robert T Turner
|
|
|
|
|
I have a third part dll COM that communicates with my C# program through the interop.
I launch my program and it works correctly.
Then I attach some events that dll COM can fire. I do nothing in those events.
Now I launch my program and it leaks.
Is there a known bug firing events from COM to .NET or using interop?
Thanks in advance.
|
|
|
|
|
Hi All.
I'v got a problem with vertical scrolling in Win form DataGridView control.
I show about 40000 rows and make it by binding rows to a DataSet.
Some time the DataSet needs to be refilled from database and I run refilling function in a new thread. Then I initialize a datasource property with the new dataset. The datagridview shows my results but the vertical scrolling seems to be disabled. It doesn't react to my mouse clicks and even doesn't show a scroll on the scrilling bar. But if I do not use the thread everything works fine. Does anybody know a workaround? Please help.
Here is my code:
ThreadGetDataSource TGDS = new ThreadGetDataSource();
TGDS.Query = query;
TGDS.CallBack = SetDataSource;
Thread t = new Thread(new ThreadStart(TGDS.ThreadProc));
t.Start();
public void SetDataSource(DataSet DS) {
if (DS != null && DS.Tables.Count > 0)
this.dgView.DataSource = DS.Tables["Data"];
this.dgView.Refresh();
}
public delegate void SetDataSource(DataSet DS);
public class ThreadGetDataSource{
public SetDataSource CallBack;
public string Query = string.Empty;
public void ThreadProc() {
DataSet DS = GetData();
CallBack(DS);
}
public DataSet GetData (){
DataSet DS;
DataTransfer DT = new DataTransfer();
DS = DT.GetDataSet(this.Query, "Data");
return DS;
}
}
I tried to use methods Update, Refresh of the DataGridVew but it doesn't help.
Tried to call Refresh on DataBindingComplete event. Doesn't help either.
Thank you.
My best regards
|
|
|
|
|
|
hi,
i have problem in uploading bitmap files that is place at the mobile device-my document to server through either synchronize or GPRS using vb.net compact frame........
Please help me here...i will very appreciate if you can me....thanks.....
best regards
Jasmine
from Malaysia
|
|
|
|
|
i have cretaed an application using odbcConnection, when i m running this exe from the network it is showing odbcpermission error. plz can any body help me to solve this thru coding in vb .net?
i do not want to use manual setting thru .NET Framework wizard.
thanks and regards
kishore
|
|
|
|
|
|
Im trying to display information from a datbase using datagrid on the website but I keep getting the following error:
'ASP.customers_aspx does not contain a definition for 'SqlDataSource1_Selecting'
anyone know why???/
|
|
|
|
|
I would go back and review the code, the key part is 'does not contain a definition for sqlDataSource1_Selecting.
tim637
|
|
|
|
|
Hi friends,
Can anyone advice me how to post some html fields to a specific url (https) using .net and c#.
Thanks and Rgds
Nithin
|
|
|
|
|
You could firstly just sent the action of the form to the destination, which would be the easiest way. However, a while back I wrote a simple class which would allow you to post to a Url from code which is included below in case you find it useful
<br />
Public Class Poster<br />
<br />
#Region " Properties "<br />
<br />
Private values As New System.Collections.Specialized.NameValueCollection<br />
<br />
Private _postUrl As String<br />
Public Property PostUrl() As String<br />
Get<br />
Return _postUrl<br />
End Get<br />
Set(ByVal value As String)<br />
_postUrl = value<br />
End Set<br />
End Property<br />
<br />
Private _formName As String = "form1"<br />
Public Property FormName() As String<br />
Get<br />
Return _formName<br />
End Get<br />
Set(ByVal value As String)<br />
_formName = value<br />
End Set<br />
End Property<br />
<br />
Private _method As String = "POST"<br />
Public Property Method() As String<br />
Get<br />
Return _method<br />
End Get<br />
Set(ByVal value As String)<br />
_method = value<br />
End Set<br />
End Property<br />
<br />
Public Sub AddValue(ByVal name As String, ByVal value As String)<br />
values.Add(name, value)<br />
End Sub<br />
<br />
<br />
#End Region<br />
<br />
#Region " Publish Methods "<br />
Public Sub Post()<br />
If PostUrl Is Nothing Then Throw New Exception("No Url specified")<br />
If FormName Is Nothing Then Throw New Exception("No Form Name specified")<br />
If String.IsNullOrEmpty(Method) Then Throw New Exception("No method specified")<br />
'if values.Count=0 then throw new Exception("No post values supplied")<br />
<br />
HttpContext.Current.Response.Clear()<br />
HttpContext.Current.Response.Write("<HTML><HEAD>")<br />
HttpContext.Current.Response.Write(String.Format("</HEAD><BODY onload=""document.{0}.submit()"">", FormName))<br />
HttpContext.Current.Response.Write(String.Format("<form name=""{0}"" method=""{1}"" action=""{2}"" >", FormName, Method, PostUrl))<br />
For i As Integer = 0 To values.Count - 1<br />
System.Web.HttpContext.Current.Response.Write(String.Format("<input name=""{0}"" type=""hidden"" value=""{1}"">", values.Keys(i), values(values.Keys(i))))<br />
Next<br />
<br />
HttpContext.Current.Response.Write("</form>")<br />
HttpContext.Current.Response.Write("</body></html>")<br />
HttpContext.Current.Response.End()<br />
End Sub<br />
#End Region<br />
<br />
End Class<br />
|
|
|
|
|
pmic:
how i can understand that , which website(url) was opened in computer?
or
which website(url) is opene in computer now
thanks.
maysam_mici @yahoo.com
|
|
|
|
|
How did this differ from the other query you posted at this permalink [^] just about three minutes back?
|
|
|
|
|
It doesn't. It's a duplicate.
|
|
|
|
|
Please don't duplicate posts. If the second post was accidental, please remove it (but only if there are no responses) otherwise remove the first post (again, only if there are no responses). If it wasn't accidental, you need to realize that the people here answer questions on a volunteer basis and will probably not respond in a timeframe you desire or find acceptable.
|
|
|
|
|
hello sir,
i am new in .net. i had made a window application in c#.net
as front end and sql-sever as back end.
now the problem is that how to install sql-server ,.netframework,and execute sql-script and my project on client computer step by step. plz give me details .
your shuaib
|
|
|
|
|
I doubt you're going to get a step by step runthrough. This is quite a length topic, and there are several good articles on this. Try searching on google for details on .net setup with sql server.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I write a C++ program which does the installation of the framework, etc, then I'd build into my app or write a seperate app that runs the scrpts to create the DB.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have created an add-in to Visual Studio 2005, and I would like to use a WCF service.
This requires a configurationfile with the configured endpoints. Normally I would create an app.config, and let visual studio build it to [appname].config in the output directory and it would work.
But when I try to access the services from the add-in, i get a configuration error that the endpoints are not configured. How do i make it open the configuration for the add-in, and not for Visual Studio?
With kind regards
Soren Bendtsen
|
|
|
|
|
If I'm in the wrong place or this is a stupid question I apologise in advance.
I am having to write a data acquisition program in .NET (C#) before I’ve had time to learn it which is making for some interesting code. What I would really like to do is reference a group of 24 progress bar components within a for/next loop using the index of the loop. Does anyone know how to do this? The code I use at the moment is very inelegant and bugs me. Would appreciate any pointers (sorry ‘bout pun)
Ted Edwards
|
|
|
|