Unable to figure out the Split File Pattern

pvsbandi
pvsbandi used Ask the Experts™
on
Greetings:
I'm not trying to bombard you with my questions, but my new requirement has forced me to post another question.
This is also related to the old question. That solution has a page split based on a pattern. And generating empty headers for the rest of them.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28472324.html#a40185820

My new attached file is a little different. But i have tried different ways to tweak the given code, but it didn't quite understand the page breaks.

Can someone kindly help again? This time, i will try to get a grasp of how the pattern is identified.
Report-03.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
oops..what i meant was
I'm Not trying to bombard you with my questions
Top Expert 2014
Commented:
This is a different report, so your pattern must change.
(1REPORT ID:\s+?SIDFA2PR(?:\s|\S)*?JURISDICTION (\d{2})(?:\s|\S)*?NUMBER/AMOUNT OF ADJUSTMENTS:\s+?\d{1,}\s+?\d[^ ]* +?\r\n)

Open in new window

And you will need to mock up a new empty report string for your strEmptyText variable, matching an empty version of your new report.

Author

Commented:
Mark,

  When i added the pattern to my logic, it is erring out at
et oTS = oFS.opentextfile(cPath & "Report-03.txt", cForReading, False, cTristateFalse)

The error is:
"Compile Error: Constant Expression Required"
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Author

Commented:
Mark, it is working! Don't know what went wrong first time, but when i reassigned the path variable as const, it worked out.
Can you please advise how i can get hold of these regular expressions?
That previous article you referred me to, is going over my head.
Top Expert 2014

Commented:
Let me describe what is happening with this pattern
(1REPORT ID:\s+?SIDFA2PR(?:\s|\S)*?JURISDICTION (\d{2})(?:\s|\S)*?NUMBER/AMOUNT OF ADJUSTMENTS:\s+?\d{1,}\s+?\d[^ ]* +?\r\n)

Open in new window

1. everything that matches the pattern inside parentheses is captured as a group.  There are two capturing groups in this pattern, one for the report page content and one for the jurisdiction number.  Capturing groups are available in the submatches collection.
2. look for "1REPORT ID:\s+?SIDFA2PR"
Note: the \s+? part of the pattern represents one or more space-like characters, which include the space character, tab character, new line character, carriage return character, and page feed character.
3. Ignore anything that comes before "JURISDICTION "
4. capture the two digits
5. Ignore anything that comes before "NUMBER/AMOUNT OF ADJUSTMENTS:"
6. there will be some white space, one or more consecutive digits, more white space, a digit followed by any non-space characters, followed by white space, followed by carriage-return line-feed characters.

(?:\s|\S)*? will match any characters (white space or non-white space) zero or more times.  The question mark at the end says "don't be greedy"

Author

Commented:
My goodness! It will definitely take a lot of practice and acquaintance to master this.
 Do you have any suggestions to practice these? like, any good book for dummies of sort..
Top Expert 2014

Commented:
of course, go through Patrick's article first.

http://www.regular-expressions.info/tutorial.html is a good start

I think that Regex Buddy is a very good tool.  They have instructional material on their web site.
http://www.regexbuddy.com/index.html

YouTube has dozens of regex tutorials

Be aware that not all regex engines support all possible patterns and uses.

I play with my patterns on MyRegexTester.com

Author

Commented:
Thanks a bunch, Mark!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial