02-01-2017 05:38 AM
I would like to know the regular expression I can use to match comments please? Such as /* This is a comment */
I would like to replace the comment with just this text "/* */" in order to save space within my variable.
Below is the code that I've been trying to use, just to see if I can match the opening of the comments tag, but I'm not sure how to do it.
without_comments = prxchange("s//\*\w+)/ /", -1, with_comments);
You're help will be greatly appreciated.
02-01-2017 06:07 AM
Sorry, what do you mean by:
"I would like to replace the comment with just this text "/* */" in order to save space within my variable."
Comments are not in a variable, they are in code. Are you storing code in a dataset or something, why?
As for replacing it, comment could be anything. Comes down to code parsing which isn't a simple matter. // is also a comment, /* could go over mutiple line. Various other things to bear in mind also.
02-01-2017 06:16 AM
Hello RW9. I'm calculating CTC grades for laboratory results, and so the algorithms along with the comments are within my variables. I'm using this alongside call execute.
I've seen a potential solution on this site, which goes over the things you have mentioned, i.e comments on multiple lines. I'm just trying to incorportate this into SAS.
02-01-2017 06:48 AM
I've seen that this code can be used to match comments. Which is similar to what that website had. I just had to escape the forward slashes too. For my example, I can just use this simple case below. Because it does find the majority of my comments (if not all). I think when the results are in the dataset there may not be the issue of comments being on multiple lines.
pattern = prxparse("/\/\*.*\*\//");
Thanks for you help.