I have a string composed of three parts.
- a number, could be 1, 2, 3, 4 or more digits.
- the word pending
- and then a date in this format: year,month,day,hour,minute,second
I would like to extract each in a variable.
Examples:
7pending20110721170832
504pending20110720110107
leonel
2
On Jul 21, 2011, at 3:15 PM, Leonel . wrote:
504pending20110720110107
This is a good place to play
(\d) => capture a single digit
(\w) => capture a single letter
leonel
3
Very easy
(\d+)(\w+)(\d{4})(\d{2})(\d{2}
)(\d{2})(\d{2})(\d{2})
Tests…
http://www.gethifi.com/tools/regex
http://nregex.com/nregex/default.aspx
2011/7/21 Leonel . [email protected]
504pending20110720110107
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Fernando A.