Ask your own question, for FREE!
Computer Science 10 Online
OpenStudy (hyroko):

This doesn't seem to work. String stuff = "System.out.println("This is a string")"; System.out.print(stuff); note, I am NOT trying to print what the inside println is calling. I'm actually looking to print out THIS actual statement to the screen. System.out.println("this is a string"); I don't want this string to be evaluated as a method call. I want to literally print this statement.

OpenStudy (hyroko):

I'm using this so that I can test regex to look for valid names in a java document. and I'm trying to make my regex ignore all words inside of quotation marks and words inside of comments.

OpenStudy (woodrow73):

Hyroko, The parser gets a bit confused when you have quotes within quotes - to get quotes inside of a String, you have to place a special character before it called an escape character. In java, I think it's a backslash: \ ``` String stuff = "System.out.println(\"This is a string\")"; System.out.print(stuff); ``` that should work. Here are the other characters that can be 'escaped' in java: http://stackoverflow.com/questions/1367322/what-are-all-the-escape-characters-in-java

OpenStudy (hyroko):

Thank you, yes, that worked.

OpenStudy (hyroko):

I'm working on making hash tables to hash all reserved words into one table, and all legal java names into another, whilst ignoring comments and strings.

OpenStudy (woodrow73):

Sounds like a fun program, good luck with it man

OpenStudy (hyroko):

yeah, final project of the semester. relatively easy, just thinking about the Regex

OpenStudy (hyroko):

Thank you

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!