Analyze COBOL source with Regex
Hello,
I try to analyze a COBOL source file, I would recognize the term "PROCEDURE DIVISION. For this I use the following pattern:
Pattern pattern = Pattern.compiles( "$^.*?(? i)\\bprocedure\\b.\\p (Space). (? i)\\bdivision\\b. * ", Pattern.Dotall | Pattern.MULTILINE );
This expression is preceded by white and only white. I tried without the line end and beginning of the line, nothing to do, it does not. Someone can help me? Thank you.
Re: Analyze COBOL source with Regex
Hello,
Proposal not guarantee the hypothesis that one or more lines are passed to the matcher
Code:
Pattern pattern = Pattern.compiles( "^\\p (Space) * procedure\\(p) + Space division .* $ ", Pattern.MULTILINE | Pattern.Case_insensitive );
- ^ \ \ p (Space) * to recognize "white" before the line
- procedure
- \ \ p (Space) + for at least one "white"
- Division
- $ .* To accept anything until the end of line
I did not put that because I do not. between procedure and division and put case_insensitive to avoid (? i).
Re: Analyze COBOL source with Regex
Hello,
I was trying for a similar problem a few days before and here is the topic now, I am the interested if you have a solution for this, by the way your assumption is correct. In fact, I have forgotten the white top of the line (like what to write the problem and reread it makes a difference). Unfortunately it does not work. What is the maximum size of a String object?
Re: Analyze COBOL source with Regex
Hello,
After rereading my algo, I found it was not good, Our solutions are both correct . I did not put dotall because I do not. between procedure and division and put case_insensitive to avoid (? i). I at least learned how to do it. Thank you again for your availability. And if you have any other alternative solution for this then please let me know.
Re: Analyze COBOL source with Regex
Hello,
Thanks for your reply guys. I understand why a file of several thousand lines did not in a String. What idea indeed. It works best with an array of String. Ok, so, even i will also use the array of string now to do the things, and if you have any information about this, then please do post back. I have tried a code for this and I have got an error, but I think I can solve the error, if no then I will post here.
Re: Analyze COBOL source with Regex
Hello,
The problem is the same for all containers that have an index (table, CharSequence, Collection, some flows, ...) and / or table internally. But in good general index 2 ^ 31-1 (2 billion +) is already not so bad. I hope you are getting the thing what we are trying to explain to you, I recommend you to have a tutorial or a documentation on the regular expression on the how to use it with cobol programming language and then write the codes for it.