Hi new to Java and as such have a question,
I would like to use an escape character / in a string
so the following line of code
System.out.println("tail -f /dat/mydata/gps/ticks | egrep \ L\ \|\ VW\");
outputs
tail -f /dat/mydata/gps/ticks | egrep \ L\ \|\ VW\
Could someone help me out please. Your help will be much appreciated.
Many thanks
using an escape character in a string
Page 1 of 15 Replies - 711 Views - Last Post: 03 June 2010 - 04:09 PM
#1 Guest_JavaMad*
using an escape character in a string
Posted 03 June 2010 - 06:35 AM
Replies To: using an escape character in a string
#2
Re: using an escape character in a string
Posted 03 June 2010 - 06:37 AM
Edit: nvm, messed up
This post has been edited by mostyfriedman: 03 June 2010 - 06:56 AM
#3
Re: using an escape character in a string
Posted 03 June 2010 - 06:43 AM
Umm, can't you simply print '/' in Java? You should be able to. '\' on the other side, must be followed by another '\', in order to get printed. Like:
prints:
Hello \
System.out.println("Hello \\");
prints:
Hello \
#4 Guest_JavaMad*
Re: using an escape character in a string
Posted 03 June 2010 - 06:43 AM
many thanks
#5
Re: using an escape character in a string
Posted 03 June 2010 - 07:42 AM
I'm not 100% what you're getting at with that command, but the following would be clearer
System.out.println("tail -f /dat/mydata/gps/ticks | egrep 'L|VW'");
#6
Re: using an escape character in a string
Posted 03 June 2010 - 04:09 PM
The escape character is \ not /
what a mess !!!
what a mess !!!
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote








|