|
I posted an example in my reply to the other answerer.
|
|
|
|
|
if your observations are correct, your IDE must be ill. Try closing and reopening it. If need be, try a reboot too. If that doesn't help, give us specifics: which OS, which IDE, and a small but actual code snippet.
|
|
|
|
|
It seems to be local only to one project, so it must be a setting somewhere...
|
|
|
|
|
I don't know any setting that would cause that.
I suggest you create a new project, move your source files (mainly the *.cs; and not the csproj and other specials) into it, try to build. If that works, delete the files (csproj and specials) you did not copy.
|
|
|
|
|
Hi,
I need help to create a colon delimited arbitrary length subfolder-ranging string based on a value. That probably makes little sense, so to demonstrate:
Value: 194356
I was hoping for a function that could take in some arbitrary 'template' definition like this:
##0000 - ##9999:####00 - ####99
and the above Value
and return something like this:
190000 - 199999:194300 - 194399
Likewise, if the 'template' were defined as:
###000 - ###999 ,
the following would be returned
194000 - 194999
and an even more finely detailed 'template':
#00000 - #99999:##0000 - ##9999:###000 - ###999:####00 - ####99:#####0 - #####9
would return:
100000 - 199999:190000 - 199999:194000 - 194999:194300 - 194399:194350 - 194350.
It also needs to work for different Value lengths, eg:
Value: 5455
'Template':
##00 - ##99
returns
5400 - 5499
The value, and the ranges, always have the same number of digits. I could easily hardcode this definition, but for reasons explained below, I don't want to do that.
Purpose (for any other ideas on how to do what I need to do):
Our Peoplesoft system generates PDF report files into a shared UNC folder. These have the filename: 000#######_<vendorname>.pdf where the 6 hashes represent a 6-digit numeric Vendor ID. I have to upload these files into our OpenText Livelink DM system. The definitions for the upload process (source path, destination, etc.) come from a custom XML file. The need for the sub folders arises from the fact that Peoplesoft generates 100's of reports per week - and shoving them into a single folder in Livelink is not acceptable to the users. If they could drill down by range, they would be happy.
Peoplesoft actually generates different types of report files in different places (Purchase orders, RFPs, etc). Some of these need more fine-tuned filing into subfolders, some do not - hence the need for a generic subfolder creating function.
I appreciate any help with this. If any more information is needed, I should be pretty speedy with the responses.
Adam
|
|
|
|
|
Not too tricky... Just break it into a few steps, assuming a standard format:
1) Split the template by the colon, and process each part individually
2) In case you want to vary the arrangement a little, use a RegEx to break down the string, finding occurrences of "#+[0-9]*"
3) For each of those patterns, find the number of digits (Assuming it'll always be a suffix-type thing), and divide the number by that power of 10 and truncate it. For example, if it was ##9 (1 digit), you'd divide by 10^1 and chop off the fractional component.
4) Replace the ## part with the resulting number
Technically you don't have to do any real calculations or test ranges, so this is just pattern matching and string replacement.
|
|
|
|
|
Here's a little Extension Method to do that. It uses a Regular Expression to find the templates, formats the value, and performs replacements.
I assumed you wanted to SPACE-pad the value, but you could change it.
public static class Junk
{
private static readonly System.Text.RegularExpressions.Regex reg ;
private static readonly System.Collections.Generic.Dictionary<string,string> dic ;
static Junk
(
)
{
reg = new System.Text.RegularExpressions.Regex
(
"(?'Template'(?'Pattern'#+)(?:(?'Fill'0+)|(?'Fill'9+)){0,1})"
) ;
dic = new System.Collections.Generic.Dictionary<string,string>() ;
return ;
}
public static string
ApplyTemplate
(
this int Value
,
string Template
)
{
lock ( dic )
{
foreach
(
System.Text.RegularExpressions.Match mat
in
reg.Matches ( Template )
)
{
string tem = mat.Groups [ "Template" ].Value ;
if ( !dic.ContainsKey ( tem ) )
{
string pat = mat.Groups [ "Pattern" ].Value ;
string fil = mat.Groups [ "Fill" ].Value ;
string temp = Value.ToString().PadLeft ( pat.Length + fil.Length ) ;
temp = temp.Substring ( 0 , temp.Length - fil.Length ) + fil ;
dic [ tem ] = temp ;
}
}
foreach
(
System.Collections.Generic.KeyValuePair<string,string> repl
in
dic
)
{
Template = Template.Replace ( repl.Key , repl.Value ) ;
}
dic.Clear() ;
}
return ( Template ) ;
}
}
|
|
|
|
|
Hi All
I am struggling to make a regular expresssion for the password policy.
There are only two requiremnts for the password policy
1. Password should of length atleast 6
2. password must contain atleast two characters at any position.
Match cases(for which regex should pass) are
1. rt5465465
2. 6556h76f
3. 76d12j
4. s45)$f
Cases for which regex should fail are
1. w565765
2. 872310
3. 4r@%&9
4. gghj
The regex whixh I have made so far are in the below code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Regex regex = new Regex("(.*[a-zA-Z].*[a-zA-Z])");
// Regex regex = new Regex("(?(^(?=.+[a-zA-Z$#%^&*()!@~+]){6,}))(?(.*[a-zA-Z].*[a-zA-Z]))(.{6,})");
Regex regex = new Regex("(^[.]*${6,})");
//Regex regex = new Regex("([a-zA-Z0-9]{6,})");
//Regex regex = new Regex("(?(?=[.]{6,})(.*[a-zA-Z].*[a-zA-Z])([Z][9][4][M][P]))");
// Regex regex = new Regex("(?(^(?=.+[a-zA-Z$#%^&*()!@~+]){6,}))(.*[a-zA-Z].*[a-zA-Z])");
// Regex regex = new Regex("(?(?=[0-9]{5,5}[a-z])([6])([1]{5,5}))");
// Regex regex = new Regex("(?(?=[0-9]{5,5}[a-z])()([1]{5,5}))");
//Regex regex = new Regex("(?(?=[a-zA-Z0-9]{6,})()(([1])([1])([p])))");
string s = textBox1.Text;
if (regex.IsMatch(s))
{
MessageBox.Show("pass");
}
else
{
MessageBox.Show("fail");
}
}
}
}
Please help
Thanks
Regards
Sandeep
|
|
|
|
|
Hi,
I wouldn't know with Regex; this is what I would do:
public bool IsValidPassword(string s) {
if (s==null || s.Length<6) return false;
int nLetters=0;
foreach(char c in s) if (Char.IsLetter(c)) nLetters++;
return nLetters>=2;
}
And someone is bound to come up with some more modern approach, probably using LINQ.
BTW: I don't think your criteria are alright; I would also require at least 2 non-letters.
|
|
|
|
|
I need RegEx for this.
Actually there is a web part (which is implemented using usercontrol) whose compiled dll is in GAC
The designer code is in file. In web part username and paasword textbox is there
There is also a login button on which the event which is in compiled assembliy in GAC get fired
I cannot write code.I know its easy using code
I am putting a regular expression validator in the designers code.So only through Regex things can be done
Please help
Thanks
Regards
THE SK
|
|
|
|
|
THE SK wrote: 2. password must contain at least two characters at any position.
Only Chuck Norris' passwords can do this.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I are Troll
|
|
|
|
|
Hello everyone. I have been struggling with learning how to program. I live in Alaska and there are not many classes I am able to attend. I would love to find Instructor led classes in my area (Anchorage) the other alternative is Online Classes. I have been reading books and Watching Videos from VTC. I have learned some but I want to be the best I can. Any help on how I can really learn C#, .NET, PHP, XML, SQL, would be great Help. Thanks
Shannon
|
|
|
|
|
If you can't get classes, then:
1) Read books, and do the exercises.
2) Try to find someone else in your area interested in the same thing.
And above all else:
3) Practice. Try it. Try it again. Do it some more. The very best way to learn is to try it yourself. Also, when you have a little confidence, try answering some of the questions here. You don't need to post your answer, but it can help to focus your mind on a problem!
Enjoy - it's a load of fun, too!
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Come up with something you want to do on your computer, and write a program to do it. Google is your friend.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Google is your friend
It's not mine. Ever since I caught it having it away with the toaster, it's banned from my door.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
you're jealous of your toaster? what got into you today?
|
|
|
|
|
John Simmons / outlaw programmer wrote: Google
Who?
|
|
|
|
|
Google, the son of Altavista, with whom you are acquainted for sure.
|
|
|
|
|
|
Hi Shannon,
I am curious to ask you, given that Anchorage is not exactly a small city (300k people ?), if you have looked around Anchorage for junior colleges, or educational institutions, night courses, extension campuses ? Is there any mobility problem, or anything else, that inhibits your getting around and visiting places like these ?
Have you googled on "anchorage c#" : [^] : looks to me like a lot of local resources there. People, companies, you might contact.
One resource I have always found helpful in almost any situation is to contact a local librarian such as may be found at : [^] : librarians these days are usually really up to date on local resources, and on-line resources, not just books.
"C#, .NET, PHP, XML, SQL" is quite a whopping plate of technology ! And I think you may want to organize your approach to learning around first trying to clarify some goals about what you want to be able to do in the future. If your long-range goal is to become a fully qualified "computer scientist" with academic credentials, that's one thing; if your goal is to, within a year or so, begin to get paid for creating web-sites that talk to databases, and support e-commerce, that's another.
And by all means, if possible, explore the various computer clubs in your area ... [^]... go the meetings, bounce off people, socialize. See if you can find someone who's willing to sit down with you and discuss your goals who's familiar with local resources.
Don't hesitate to find out the open office hours of an instructor or professor at a local junior college or college in computer science and drop in, introduce yourself; most likely you'll get a friendly greeting and, possibly, some good advice.
good luck, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
I am learning further in C# and came across a special requirement of collections. I wonder if such implementations exists.
I need a list with a key and multiple values. After the first entry, next entries can be partial only to denote a change. Something like this:
index value1 value2 value3 Result value1 value2 value3
1 100 200 300 - 100 200 300
2 200 - 100 200 200
3 150 300 - 150 200 300
4 250 - 150 250 300
5 100 200 - 100 200 300
This can be achieved using DataTable and using select statements/compute etc. But, is there a simpler option available? Speed is the key here.
----------------------------Question Modified----------------------------------
Please understand that creating a list/dictionary/array/hashtable is not the problem here. Storing the data is easy. This could be done using numeric Key/Index (I can manage to keep indexes of the keys also).
The idea is to be able to look for the last fetched value against each key. The problem comes when I want to retrieve he value without having to loop again. Look at the same example with modified index values.
index value1 value2 value3 Result value1 value2 value3
100 100 200 300 - 100 200 300
200 200 - 100 200 200
300 150 300 - 150 200 300
400 250 - 150 250 300
500 100 200 - 100 200 300
Consider the next step. if I want to find out the value for key 250, I would want to look for 200, and then find results for it.
Is it possible without going through loops again?
Current Solution:
I created a class as:
class DataClass
{
int Value1; int Value2; int Value3
int ValueIndex1; int ValueIndex2; int ValueIndex3;
}
Then for each entry done, I need to run the loop once to find out the last index for which entry was done against the value and store it.
Dictionary<int, DataClass> entries = new Dictionary<int, DataClass>();
entries.Add(100, new DataClass(100,200,300, 100,100,100);
entries.Add(200, new DataClass( 0,150, 0, 100,200,100);
entries.Add(300, new DataClass( 0, 0,250, 100,200,300);
entries.Add(400, new DataClass(150, 0, 0, 400,200,300);
entries.Add(500, new DataClass( 0,200, 0, 400,500,300);
Now, whenever i need to look for 250, i search for closest smaller key (here that is 200). find values. whatever is available is taken as it is. For all others, find the key in the same record and get the new entries.
This solution works for the first time entries. However it creates problems when an entry is inserted in between. Another logic needs to be built in between.
Can there be something faster than this?
----------------------------------
modified on Thursday, December 17, 2009 12:58 AM
|
|
|
|
|
Have each object maintain a dictionary of values. In the samples you rpovided above:
Index 1 would contain
1,100
2,200
3,300
Index 2 would contain
3, 200
Index 3 would contain
1, 150
3, 300
Index 4 would contain
2,250
Index 5 would contain
1,100
2,200
Use google to learn how to use dictionary collections.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Thanks for the attempt.
I have modified the question for all the responses. Answering the same answer to all replies was not a good idea.
Please give it a read.
|
|
|
|
|
Value1, value2 and value3 are distinct entities that you want to track? A dictionary consists of a value and a key. The key would be your index-column, the value could be a struct that holds the three columns;
System.Collections.Generic.Dictionary<int, MyValues> myListOfValues;
struct MyValues
{
int value1;
int value2;
int value3;
} You could consider the generic list as your datatable, and the struct as a single row in that table. Now you can add values to your dictionary;
MyValues oneRow = new MyValues();
oneRow.value1 = 100;
oneRow.value2 = 200;
oneRow.value3 = 300;
myListOfValues.Add(1, oneRow); Now, if you want the recreate those values for index 3, you would have to search in the list for the first non-empty value for the column value2.
If speed is important, then I'd create one row outside of that list, just to mirror the current values. That wouldn't help if you need the values from the middle of the index, you'd still have to walk the list for that.
How many records will be in that list? It might just be worth to store copies of the latest value, instead of looking for them.
I are Troll
|
|
|
|
|