Click here to Skip to main content
15,116,653 members
Home / Discussions / C#
   

C#

 
QuestionRe: load dataGrid C# Pin
toto_201016-Apr-10 2:58
Membertoto_201016-Apr-10 2:58 
AnswerRe: load dataGrid C# Pin
Morgs Morgan16-Apr-10 3:41
MemberMorgs Morgan16-Apr-10 3:41 
GeneralRe: load dataGrid C# Pin
toto_201016-Apr-10 5:20
Membertoto_201016-Apr-10 5:20 
QuestionReguler expression [modified] Pin
bhaskarsgb16-Apr-10 0:23
Memberbhaskarsgb16-Apr-10 0:23 
AnswerRe: Reguler expression Pin
riced16-Apr-10 2:33
Memberriced16-Apr-10 2:33 
GeneralRe: Reguler expression Pin
bhaskarsgb16-Apr-10 2:54
Memberbhaskarsgb16-Apr-10 2:54 
GeneralRe: Reguler expression Pin
Gideon Engelberth16-Apr-10 3:52
MemberGideon Engelberth16-Apr-10 3:52 
GeneralRe: Reguler expression Pin
JTS16-Apr-10 3:57
MemberJTS16-Apr-10 3:57 
You can use a tool like Espresso to build your regular expressions. The link is http://www.ultrapico.com/Expresso.htm[^]


Here is the regex I came up with:

(?:!(?<JobId>\w*)(?:.*?),(?:.*?))?(?:;(?<Field1>\w*)?/??(?:.*?))?:(?<Field2>\w*)??/





Expresso will generate the following C# code for you:


<br />
//  using System.Text.RegularExpressions;<br />
<br />
/// <summary><br />
///  Regular expression built for C# on: Fri, Apr 16, 2010, 07:52:19 AM<br />
///  Using Expresso Version: 3.0.3634, http://www.ultrapico.com<br />
///  <br />
///  A description of the regular expression:<br />
///  <br />
///  Match expression but don't capture it. [!(?<JobId>\w*)(?:.*?),(?:.*?)], zero or one repetitions<br />
///      !(?<JobId>\w*)(?:.*?),(?:.*?)<br />
///          !<br />
///          [JobId]: A named capture group. [\w*]<br />
///              Alphanumeric, any number of repetitions<br />
///          Match expression but don't capture it. [.*?]<br />
///              Any character, any number of repetitions, as few as possible<br />
///          ,<br />
///          Match expression but don't capture it. [.*?]<br />
///              Any character, any number of repetitions, as few as possible<br />
///  Match expression but don't capture it. [;(?<Field1>\w*)?/??(?:.*?)], zero or one repetitions<br />
///      ;(?<Field1>\w*)?/??(?:.*?)<br />
///          ;<br />
///          [Field1]: A named capture group. [\w*], zero or one repetitions<br />
///              Alphanumeric, any number of repetitions<br />
///          /, zero or one repetitions, as few as possible<br />
///          Match expression but don't capture it. [.*?]<br />
///              Any character, any number of repetitions, as few as possible<br />
///  :<br />
///  [Field2]: A named capture group. [\w*], zero or one repetitions, as few as possible<br />
///      Alphanumeric, any number of repetitions<br />
///  /<br />
///  <br />
///<br />
/// </summary><br />
public static Regex regex = new Regex(<br />
      "(?:!(?<JobId>\\w*)(?:.*?),(?:.*?))?(?:;(?<Field1>\\w*)?/??(?"+<br />
      ":.*?))?:(?<Field2>\\w*)??/",<br />
    RegexOptions.Multiline<br />
    | RegexOptions.CultureInvariant<br />
    | RegexOptions.Compiled<br />
    );<br />
<br />
<br />
<br />
//// Replace the matched text in the InputText using the replacement pattern<br />
// string result = regex.Replace(InputText,regexReplace);<br />
<br />
//// Split the InputText wherever the regex matches<br />
// string[] results = regex.Split(InputText);<br />
<br />
//// Capture the first Match, if any, in the InputText<br />
// Match m = regex.Match(InputText);<br />
<br />
//// Capture all Matches in the InputText<br />
// MatchCollection ms = regex.Matches(InputText);<br />
<br />
//// Test to see if there is a match in the InputText<br />
// bool IsMatch = regex.IsMatch(InputText);<br />
<br />
//// Get the names of all the named and numbered capture groups<br />
// string[] GroupNames = regex.GetGroupNames();<br />
<br />
//// Get the numbers of all the named and numbered capture groups<br />
// int[] GroupNumbers = regex.GetGroupNumbers();<br />
<br />
<br />
<br />


I hope this helps. I wrapped each section in a non-capturing group with the ? option to account for cases where the field 1 may not be present.
GeneralRe: Reguler expression Pin
OriginalGriff16-Apr-10 5:58
mveOriginalGriff16-Apr-10 5:58 
GeneralRe: Reguler expression Pin
bhaskarsgb16-Apr-10 8:17
Memberbhaskarsgb16-Apr-10 8:17 
AnswerRe: Reguler expression Pin
Morgs Morgan16-Apr-10 3:57
MemberMorgs Morgan16-Apr-10 3:57 
QuestionCreating videos from images Pin
TimSWatson16-Apr-10 0:15
MemberTimSWatson16-Apr-10 0:15 
AnswerRe: Creating videos from images Pin
Luc Pattyn16-Apr-10 1:13
sitebuilderLuc Pattyn16-Apr-10 1:13 
AnswerRe: Creating videos from images Pin
annathor16-Apr-10 2:18
Memberannathor16-Apr-10 2:18 
AnswerRe: Creating videos from images Pin
TimSWatson16-Apr-10 2:59
MemberTimSWatson16-Apr-10 2:59 
GeneralRe: Creating videos from images Pin
ragnaroknrol16-Apr-10 4:02
Memberragnaroknrol16-Apr-10 4:02 
GeneralRe: Creating videos from images Pin
TimSWatson16-Apr-10 4:26
MemberTimSWatson16-Apr-10 4:26 
GeneralRe: Creating videos from images Pin
ragnaroknrol16-Apr-10 5:41
Memberragnaroknrol16-Apr-10 5:41 
QuestionDevelop IE plugin in C# to show custom content Pin
Olivier Baillard15-Apr-10 23:08
MemberOlivier Baillard15-Apr-10 23:08 
AnswerRe: Develop IE plugin in C# to show custom content Pin
Ravi Bhavnani17-Apr-10 21:32
professionalRavi Bhavnani17-Apr-10 21:32 
GeneralRe: Develop IE plugin in C# to show custom content Pin
Olivier Baillard3-Jun-10 22:01
MemberOlivier Baillard3-Jun-10 22:01 
Questionselect distinct rows along with some condition [modified] Pin
NarVish15-Apr-10 23:01
MemberNarVish15-Apr-10 23:01 
AnswerRe: select distinct rows along with some condition Pin
Calla15-Apr-10 23:14
MemberCalla15-Apr-10 23:14 
GeneralRe: select distinct rows along with some condition Pin
NarVish15-Apr-10 23:33
MemberNarVish15-Apr-10 23:33 
GeneralRe: select distinct rows along with some condition Pin
NarVish16-Apr-10 5:08
MemberNarVish16-Apr-10 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.