[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

Unable to figure out the Split File Pattern

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
0
pvsbandi
Asked:
pvsbandi
  • 5
  • 3
1 Solution
 
pvsbandiAuthor Commented:
oops..what i meant was
I'm Not trying to bombard you with my questions
0
 
aikimarkCommented:
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.
0
 
pvsbandiAuthor 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"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pvsbandiAuthor 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.
0
 
aikimarkCommented:
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"
0
 
pvsbandiAuthor 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..
0
 
aikimarkCommented:
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
0
 
pvsbandiAuthor Commented:
Thanks a bunch, Mark!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now