Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. regular expression for spaces and words
  2. <div>
  3.     <asp:HyperLinkField HeaderText="Hello World of Regular Expression" />
  4. </div>
  5.        
  6. //This one gets me close but doesn't get me strings with spaces in them
  7. var match = Regex.Match(tokens[1], @"HeaderText=""(w+)""");
  8. //This was suggested below. It shows correct match count but values are just empty strings
  9. var match = Regex.Match(tokens[1], @"HeaderText=""[^""]+""|[w]+");
  10.  
  11. if (match.Success)
  12. {
  13.     yield return new KeyValuePair<string, string>(
  14.         file, match.Groups[1].Value //This is empty for 2nd scenario
  15.     );
  16. }
  17.        
  18. "[^"]+"|[w]+