|
Yes, I understand that.
Let's see...
Fact 1 : The text to be tested contains TAB characters that need to be matched.
Fact 2 : To match TAB characters with a regular expression you specify \t (not an actual TAB character).
Fact 3 : The string produced by the C# statement string s="\t"; will contain a TAB character, not the desired \t (even though the debugger may show it as \t ).
Fact 4 : To produce a string in C# that does contain the two-characters \t , use either string s=@"\t"; or string s="\\t";
If that's not the problem, then I don't know what is and I hope someone else steps up.
|
|
|
|
|
Yes on all accounts. The regular expressions in code are @-quoted. Here's a snippet of the declarations within the factory class (there are other types of messages in different formats that can be received and I use these expressions to identify and parse). You can tell the one that's in issue, because it comes up with the smiley!
private const string _patternReturnDataSet = @"\A\d{2}[\s\t]+(?<Column>\w+[,\t]\d+[,\t]\d*[,\t])+[\n\r\f]+(?<Row>(?:[^,\t\n\r\f]*[,\t])+[\n\r\f]+)*{DONE}\z";
private const string _patternReturnVariant = @"\A\d{2}[\s\t]+(?<Text>.[^\t]*){DONE}\z";
private const string _patternError = @"\A\d{2}[\s\t]+(?<ErrorMessage>.[^\t]*)[\s\t]+(?:.[^,]*,[\s\t])*(?:.[^;]*;)[\s\t](?<ErrorNumber>\d*)[;][\s\t]+{DONE}\z";
private const string _patternInvalidCommand = @"\A(?:\d{2}[\s\t]+)?(?<ErrorMessage>.[^;]*)[;\s\t]+{DONE}\z";
private const RegexOptions _options = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Multiline;
|
|
|
|
|
Huh, alright, now I'm stumped. But I'll try this out myself and maybe learn something.
Fortunately, this latest post also came into my email so I have a no-smiley version of the line to use.
-- modified at 11:52 Saturday 16th June, 2007
Hmmm, I get:
System.Text.RegularExpressions.RegexParser(ScanGroupOpen)parsing "\A\d{2}[\s\t]+(?.[^\t]*)[\s\t]+(?:.[^,]*,[\s\t])*(?:.[^;]*;)[\s\t](?\d*)[;][\s\t]+{DONE}\z" - Unrecognized grouping construct.
-- modified at 12:17 Saturday 16th June, 2007
I added names for the capturing groups (I assume you specified names but used angle-brackets, try apostrophes)
@"\A\d{2}[\s\t]+(?'ErrorMessage'.[^\t]*)[\s\t]+(?:.[^,]*,[\s\t])*(?:.[^;]*;)[\s\t](?'Number'\d*)[;][\s\t]+{DONE}\z"
But it doesn't match... yet.
-- modified at 12:35 Saturday 16th June, 2007
OK, it matches, and misbehaves as described.
-- modified at 12:51 Saturday 16th June, 2007
The missing text is going to the second non-capturing group (I made it capture just to see).
It appears the first group isn't being greedy enough.
-- modified at 13:02 Saturday 16th June, 2007
This
@"\A\d\d\t(?'ErrorMessage'[^\t]*)\t;\s*(?'Number'\d*);\s*{DONE}\z"
works on the sample provided.
-- modified at 13:16 Saturday 16th June, 2007
First, I'll say that \s includes \t, so [\s\t] can be simplified to \s
Other than that, I changed this V from a + to a * and it seems to work
@"\A\d{2}\s+(?'ErrorMessage'.[^\t]*)\s*(?:.[^,]*,\s)*(?:.[^;]*;)\s(?'Number'\d*);\s+{DONE}\z"
I would also remove these ^ ^ ^
|
|
|
|
|
Just trying again, to see if I can have the pre tags but no smiley
Other than that, I changed this V from a + to a * and it seems to work
@"\A\d{2}\s+(?'ErrorMessage'.[^\t]*)\s*(?:.[^,]*,\s)*(?:.[^;]*; )\s(?'Number'\d*);\s+{DONE}\z"
I would also remove these ^ ^ ^
I guess not, so I added the SPACE.
|
|
|
|
|
Thanks for all your work on this. I'm stumped too. I hoped that I was missing something obvious.
I'm actually using Regex.Match for the work I'm doing. The capturing groups seem to work fine except for the one mentioned whether I use the < or the '. I cannot get it to match if I leave out the \t -- I wonder why it works for you, are you using the same Regex options that I am? (The \s is in there as well, because the delimiter isn't necessarily always a \t -- it's a crappy legacy system I have nothing to do with.)
So far no luck. This is very odd.
|
|
|
|
|
I think the culprit is that +, but I don't know why it would work in one system and not the other.
I am using the same options, and using .Matches to be sure I get only the one match.
|
|
|
|
|
I used the +, because I want to match one or more. I cannot rely on the legacy application to have only one, but it must have at least one. I'm nervous about cascading problems by switching the + to a * that I may not discover until later.
|
|
|
|
|
Yes, but it's causing the problem. Because you require at least one, it uses the SPACE that should be part of the first group. By allowing zero, that doesn't happen.
All in all, that regex is more complex than needed for the given sample.
Are there other samples you can provide?
|
|
|
|
|
I'm just finally getting back to this after several projects sidelined the longer term project that this regular expression is used in. It seems using the * does the trick -- all my unit tests are passing. I gave you a "5". Sorry it's belated.
|
|
|
|
|
Prot a noblem, glad it worked.
|
|
|
|
|
How to do Asynchronous web service call (using delegates and threading)? Please advice me?
Rgds
Nithin
|
|
|
|
|
Web Method by default are created with Being and End procedures too.
Call Begin of our desired method.
There is no need of multi threading...
|
|
|
|
|
Manas Bhardwaj wrote: There is no need of multi threading...
Well, strictly speaking the .NET Framework handles the multithreading for you. There is still multithreading going on.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
i have done many times setup visual studio but soon before i made format my notebook than i can setup visual studio.i setup first setup(windows installer 3.1).but when programme try to setup .net 2.0 so last of progress bar so setup cant go on.But i cant see any error problem.just progress bar stands last of progress bar.another odd thing is that in the near of the progress bar s pictures change.
|
|
|
|
|
Any specific error message?
|
|
|
|
|
hi,
At this time i'm ready to do the OCR project based on CLR in vc++. But, my code snippet giving an error when the c++/clr compile the particular line....
void Form1::SOCR_Click(System::Object^ sender, System::EventArgs^ e)<br />
{<br />
int i,j,k;<br />
String^ fName = "Citi.tif";<br />
MODI::Document^ doc = gcnew MODI::DocumentClass();<br />
doc->Create(fName);<br />
doc->OCR(MODI::MiLANGUAGES::miLANG_SYSDEFAULT,true,true);<br />
<br />
for(i=0; i < doc->Images->Count; i++)<br />
{<br />
MODI::Image^ img =(MODI::Image) doc->Images[i];<br />
}<br />
<br />
}
where,
Image - Interface class
The Error is...
Error 1 error C3149: 'MODI::Image' : cannot use this type here without a top-level '^'
please help me...
thanks in advance...
|
|
|
|
|
Have a look at this:
http://msdn2.microsoft.com/en-us/library/x9y91h72(vs.80).aspx
I think it is your problem, isn´t it?
If not sorry!
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
This question belongs in the (Managed)C++/CLI forum.
|
|
|
|
|
You're casting to a MODI::Image instead of a MODI::Image ^.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Hi I am a newbie in learning .Net now.
I had in mind of writing something similar to a COM standalone executable and my GUI frontend executable will communicate with this server. Does .Net have anything like this?
Please enlighten me!
Thanks for your time!
|
|
|
|
|
Yes - you can achieve this effect using Reflection or Remoting.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, thanks for the reply!
I got another question, the so-called server I am going to write is on the same computer as the GUI executable, it is not on a remote server or another networked computer. Does that work as well?
Thanks again!
|
|
|
|
|
.NET Remoting yes.
Refelection has nothing to do with interprocess communication.
only two letters away from being an asset
|
|
|
|
|
how do i configure whereby vs2005.net works with framework 1.1???
tks
chris
|
|
|
|
|