Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
const string numericReg = "\\d+"; // Matches a digit character. Equivalent to [0-9].
const string realNumsReg = numericReg + b + "(\\." + b + numericReg + ")?";
        const string b = "\\s*";



This statement is true :

C#
private const string rte = "(?<rate>" + realNumsReg + ")" +
                          "(?=(?<rte1>" + b + "qs " + "))";


and

This statement is true :

C#
private const string barl = "(?<barl>" + numericReg + ")" +
                                   "(?=((?<q>" + b + "point to print )))";



this is true for rte :

C#
MatchCollection s = Regex.Matches
                ("3000 qs / min", rte , RegexOptions.IgnoreCase);


this is true for barl:

C#
MatchCollection s = Regex.Matches
                ("6 point to print  ", barl , RegexOptions.IgnoreCase);


Why is this wrong?

C#
MatchCollection s = Regex.Matches
               ("6 point to print  3000 qs/ min", barl+b+rte  , RegexOptions.IgnoreCase);
Posted
Comments
Peter_in_2780 2-Oct-12 9:33am    
Grab Expresso (see our free tools forum for link).
A quick look at your code raises a few questions:
1. your numericReg allows whitespace after a decimal point. do you really want this?
2. in 'rte', did you mean the named groups (rate, rte1) to have the same name?
3. likewise in 'bar1' for bar1 and q.
4. in your last test expression, you are missing the space between qs and /.
Sergey Alexandrovich Kryukov 2-Oct-12 12:51pm    
Good reply, a 5 ;-)
--SA

1 solution

Use this pattern with ExplicitCapture as an option:
\b*(?<points>\d{1}) point to print (?<qs>\d{1,4})\b</qs></points>

Result -> 2 matches: 6 and 3000

Is that you're looking for?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900