Hello,
I am trying to craft a regex to match everything between the 25th and 130th character in a line. I am having no success. Someone suggested ^.{25} (?P<FIELDNAME>.{130}
but that doesn't work at all. Does anyone know how to create this regex?
Thank you!
The regex you provided will first match characaters 1-25. The capturing group (while incomplete) would then catch the next 130 characters, not upto the 130th character.
Try this: ^.{25}(?P<fieldname>.{1,105})
. This should grab everything from 25-130, and will also grab anything that may be less than 130.
Depending on what you are trying to accomplish, you may be better off using the eval substr() function. For example:
... | eval newField=substr(field, 26, 104)
Otherwise, you can use this regex to extract the same thing:
^.{25}(?P<newField>.{0,105})
The regex you provided will first match characaters 1-25. The capturing group (while incomplete) would then catch the next 130 characters, not upto the 130th character.
Try this: ^.{25}(?P<fieldname>.{1,105})
. This should grab everything from 25-130, and will also grab anything that may be less than 130.
This works perfectly ^.{25}(?P
Thank you!