Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    Note that str.find returns -1 for missing sub-strings, that should be handled as well. Commented Feb 3, 2014 at 18:17
  • I never thought of using regex, I'm not that well versed in it. But the given regex code, how does it read (find string "" and return ..)? Commented Feb 3, 2014 at 20:55
  • Take a look at regex101.com/r/aX9yI6 - it might help. Basically, the (?:...) means "look for ... but don't capture it (i.e. return it in output)". The \s* means "look for any amount of whitespace". Finally, (\d+) means "look for one or more digits, and capture it (i.e. return it in output)". Commented Feb 3, 2014 at 21:00