We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

Unable to figure out the Split File Pattern

pvsbandi
pvsbandi asked
on
307 Views
Last Modified: 2014-08-07
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.
https://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

Author

Commented:
oops..what i meant was
I'm Not trying to bombard you with my questions
Social distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

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"

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.
aikimarkSocial distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
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..
aikimarkSocial distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
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!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.