What would be a RegExp equivalent of substring from position x to position y?
For example:
0001..STACK.OVERFLOW...IS.AWESOME.13052011
I know that the value of a field called 'status' in this fixed length string is 8 characters starting from position 26. What would a regex in JavaScript (and Java) look like to get the "AWESOME" string?
I’m trying to build a parser of mainframe screens that come over JMS as fixed length strings. And the idea is to write a UI where a user could highlight a section of a string, fill the ‘field name’ field, select type (int, String..) and have a Java class generated automatically.
The first .{26} eats the first 26 characters no matter what they are. The (.{8}) captures the next 8 characters and stores them. For Javascript you can use
and matches[1] will be the substr that you’re looking for. (matches[0] always contains the entire matched string)
note that the .s can be replaced by character classes if you want (ex. [\w]{26}[\w]{8})