|
|
Thank you Richard. I was able to put a regular expression together which was rather long and ugly but did exactly what I needed. Much appreciated.
|
|
|
|
|
Why is it long? A Regex to extract the times is pretty trivial:
[012]?\d:\d\d would work,or even
\d:\d\d if the time is midnight - ten AM (less one second)
For real accuracy it should be
[012]?\d:[0-5]\d to prevent 15:67 being accepted, but ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Ah - you run on Mercury time: no problemo ... one alarm set for October ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's why I'd probably stick with [012]?\d:\d\d - then post process the Matches collection to eliminate bad times. Much simpler, cleaner and more obvious than the "full on" regex! (And a whole load easier to maintain when the requirement changes)
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yep. The one I find a perpetual PITA is dotted decimal IPv4 addresses, particularly if you allow for all the corner cases. And as for IPv6, the less said the better.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thanks folks, really appreciate the responses.
OriginalGriff wrote: Why is it long? A Regex to extract the times is pretty trivial:
It was long because I am pretty new to regular expressions and really just needed to get it done, rather than work on the most efficient expression. But thanks to you guys, I now have a much more effective way to do it. Since last night I have read up on the topic more and have a better grasp.
Thanks again!
free-pizza
|
|
|
|
|
If you are going to use Regular Expressions - and it's a good idea sometimes - then get a copy of Expresso[^] - it's free, and it examines, tests, and generates Regular expressions.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Got an odd one I could do with some advice on...
I have a base form all my decendent data entry forms are based on. The base form had some menus defined on it with icons on the various menu options. This means all the child data entry forms have them too. So far so good.
I decided to update the icons on the base form, thinking this change would automatically cascade down to all the child forms but no, they don't. When I open the resources file for each child form, they have a separate copy of the icons.
Why would this be - surely it defeats the whole point of visual inheritance?
Any suggestions on how I can update all the icons on the child forms to match? I can't go through them one by one and manually adjust as I have several hundred forms in the application.
Many thanks.
|
|
|
|
|
Did you do a rebuild? Or just recompile?
|
|
|
|
|
|
It's really strange - when I create a really simple project with just 2 forms - a parent and inherited child, it behaves correctly.
|
|
|
|
|
OK, I just tried it: A MainForm and a BaseForm from which it derives.
I add a small menu strip to the BaseForm, and assign Image properties to each menu item.
Derive the MainForm from BaseForm, and run it: MainForm has the menus, with the correct icons.
Check the Image for one of the BaseForm menu items, run it again: the menus are there, and are using the new images.
So what am I doing that is different from you?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks for the response. I don't know. On my simple test it also worked. But on my application that hundred of forms and a quite complex set of base forms it doesn't work. Really at a loss.
|
|
|
|
|
Are you running a single project solution, or are these mixed across assemblies?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Running across multiple assemblies.
I think I may have got to the bottom it. I created a brand new inherited form from the base form and it behaved correctly. On comparing the designer.cs code of the new form with one of my original (problematic) inherited forms, it looks like a load of extra code has been inserted into the code behind the designers.
For Example:
//
// bsiAdd
//
this.bsiAdd.ImageOptions.Image = ((System.Drawing.Image)(resources.GetObject("bsiAdd.ImageOptions.Image")));
This seems to have also pushed the images into the resx file. If I remove all the bits of code for about 50 menu items then remove the images manually from the resx file then the inheritance seems to work properly.
The only thing I can think of which might have caused this is I put a DevExpress SharedImageCollection onto my main window form and I'm thinking that the nature of this control has perhaps caused this.
Issue I have now is I have to apply my manual fix to several hundred forms!
modified 27-Aug-20 10:07am.
|
|
|
|
|
Intern?
Office Junior?
Someone you can con into it?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Good idea unfortunately, it gets weirder by the minute. If I apply my fix then open the designer and make any change at all to the design surface of the screen and save it, it puts the code back I deleted and re-adds the images back into the resource file!
|
|
|
|
|
At a guess it is because you are getting the form from a resource file, the above tests are probably just using an inherited form and not a resource object.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I think that is the likely cause since the base form is in a different assembly. It would make sense that VS is trying to make sure the image is still available to the child forms in a different assembly by copying the resource into the resx file. I'll try moving the base form into the same assembly to see if it resolves the issue. Thanks.
|
|
|
|
|
Hello all. I am asking this for my wikipedia editing. I am not from the background of computer science but I edit wikipedia a lot.
I am using a software called as auto wiki browser to edit: brief intro to AWB - Wikipedia[^] AWB is a very powerful tool. It also supports modules.Wikipedia:AutoWikiBrowser/Custom Modules - Wikipedia[^] also regex.
I am running a find and replace task using awb. I wants to add some rules for skipping.
My exact problem in short: on wikipedia there are many pages called as disambiguation page for example: Robert Abel - Wikipedia[^]
This Robert Abel page lists all the persons named Robert Abel and nothing else. Ideally no wiki page should link to Robert Abel. The pages should link to particular Roberts. For example Robert Abel (animator)[^] or Robert Abel (footballer).
What I wants to do is: AWB makes a list of all the pages linking to Robert Abel (base page). I wants to search for Robert Abel and replace it with Robert Abel (animator). But if the text is "Robert Abel (footballer)" or "Robert Abel (racing driver)" then I wants to skip it.
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "fix wikilink";
ArticleText = ArticleText.Replace("Robert Abel", "Robert Abel (animator)");
return ArticleText;
}
I tried the above code in AWB module. But if there is already "Robert Abel (animator)" in the article then it addings "Robert Abel (animator) (animator)". I tried to add else parameter but it giving compilation error. This is faulty code:
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "fix wikilink";
ArticleText = ArticleText.Replace("Robert Abel", "Robert Abel (animator)");
if ArticleText = "Robert Abel (animator)" {
Skip = true;
} else {
ArticleText.Replace("Robert Abel", "Robert Abel (animator)");
}
return ArticleText;
}
Update edit: I thinks it is giving error because of the bracket of (animator) after else. idk.
I wants to add few different rules. example: skip if "A" or "B" or "C" is present. If "D" is present then change it to "E". If "F" is present then change it to "G". If I can get one example then I can do the rest with monkey sees monkey does principle.
The problem comes with text after "Robert Abel". How to tell the program to not to make any changes/skip that one particular instance when there is "Robert Abel (animator)" or "Robert Abel (footballer)", and then to look for next instance of only "Robert Abel"?
Please help me. But I am not from background of computer science so please explain in way that I will understand. I also asked the same question on this same website: How to perform find and replace with condition in C# and/or regex?[^]
modified 26-Aug-20 14:21pm.
|
|
|
|
|
This is teh same question you asked yesterday: How to perform find and replace with condition in C# and/or regex?[^] - the answer you have has not changed in that time ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi OriginalGriff. I pointed out in the bottom that I already asked the question, with a link. I posts here, because I thinks this is the correct venue. Please help if you can.
|
|
|
|
|
Hi,
I just wanted to point out that the wikipedia disambiguation bot already exists[^]. I highly doubt another bot that does the same thing will gain WP:BOTAPPROVAL consensus.
|
|
|
|