Thinking In Java
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ruslan Salimych wrote:Could you please say how to create a regex for the following task:
it does not find comments like these /*....*/
it does not find comments that are located after " signs, like this: String s = "this is me"; //Comment
All things are lawful, but not all things are profitable.
For single line comments, you need to match "//" and everything that follows it, until the next end-of-line.
All things are lawful, but not all things are profitable.
Ruslan Salimych wrote:Could you please say how to create a regex for the following task:
"Write a program that reads a Java source-code file (you provide the file name on the command line) and displays all the comments."
it does not find comments like these /*....*/
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Knute Snortum wrote:Hmm, what about this line?
All things are lawful, but not all things are profitable.
Stephan van Hulst wrote:
Knute Snortum wrote:Hmm, what about this line?
What about it? I can easily write a regex that will find the comment within that line.
Thinking In Java
Paul Clapham wrote:Don't forget about the possibility of Unicode escapes in the source code.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Paul Clapham wrote:
Don't forget about the possibility of Unicode escapes in the source code.
Thinking In Java
Stephan van Hulst wrote:What about it? I can easily write a regex that will find the comment within that line.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ruslan Salimych wrote:So I see that first I have to define what is comment, and only then start solving a problem, since I see there are a lot of variants of comments.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Hmmm, really? And what about [...]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |