January 7th, 2012, 02:02 AM
Using Regular Expression to Parse MICR Cheque data
I have a string with MICR data from bank cheques.
I want to parse this string using Regular Expressions, I am very new to regular expression. Am I in the right direction of using the regular expression to parse this?
Following is sample data:
January 7th, 2012, 12:36 PM
Actually you probably don't need them. Since they're all predictably long (they're all X or Y digits long, apparently) you can just use regular string methods to get the pieces you want.
For example, the MMDD (I think) starts at the ninth character in for each one.
January 7th, 2012, 05:19 PM
requinix makes an excellent point. If your input all has the same shape, then substr() and its friends are your friends.
Seeing that the last string in your input is longer, substr() still helps on shorter strings when you try to grab the faraway digits (returning FALSE), or you can use strlen().
Nevertheless, for the sake of discussion, if your codes occurred at unpredictable locations in a file... Then yes, you are right that regular expressions would be a perfect tool for that.