Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 :
 
  private const string rte = "(?<rate>" + realNumsReg + ")" +
                            "(?=(?<rte1>" + b + "qs " + "))";
 
and
 
This statement is true :
 
 private const string barl = "(?<barl>" + numericReg + ")" +
                                    "(?=((?<q>" + b + "point to print )))";
 

this is true for rte :
 
MatchCollection s = Regex.Matches
                ("3000 qs / min", rte , RegexOptions.IgnoreCase);
 
this is true for barl:
 
MatchCollection s = Regex.Matches
                ("6 point to print  ", barl , RegexOptions.IgnoreCase);
 
Why is this wrong?
 
 MatchCollection s = Regex.Matches
                ("6 point to print  3000 qs/ min", barl+b+rte  , RegexOptions.IgnoreCase);
Posted 2-Oct-12 0:03am
Comments
Peter_in_2780 at 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 at 2-Oct-12 12:51pm
   
Good reply, a 5 ;-)
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use this pattern with ExplicitCapture as an option:
\b*(?\d{1}) point to print (?\d{1,4})\b
 
Result -> 2 matches: 6 and 3000
 
Is that you're looking for?
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 360
1 Gihan Liyanage 332
2 ClimerChinna 222
3 OriginalGriff 206
4 Richard MacCutchan 170
0 Sergey Alexandrovich Kryukov 8,298
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,005
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100