Writing a quick app to help me filter text files.
I’m reading in a text file line-by-line, and need to match a series of characters that looks like this: 090129 YBB 100
The first set, 090129, will be 6 numbers (0-9). Followed by a space, and then YBB – always. After that, another space, then 2-3 numbers (0-9).
This pattern will always be the first part of the string as well.
Here’s my hack at it:
^[0-9][0-9][0-9] (YBB) [0-9][0-9][0-9]\b
Of course, doesn’t work… but I’m a regex noob. Thanks in advance!
Here goes:
Explanation:
a) Start at start of line. b) Match 6 digits. Save into backref 1. c) Match a space. d) Match ‘YBB’. Don’t save into backref. e) Match a space. f) Match 2-3 digits. Save into backref 2.
Of course, it’s important to know which part of this pattern you want to retrieve into a backreference. If you provide that info, I can edit my post.