Question:
simple java question about regular expression?
2013-03-30 18:54:16 UTC
Write a regular expression  that selects lines containing the pattern shell. For this exercise you must surround your solution with double quotes .

this is the question but sadly, I cannot understand :(
plz help me solve it!
Three answers:
Kaydell
2013-04-03 01:58:34 UTC
"^.*shell.*$"



The regular expression above would select lines of text that have the word "shell" in them. Is that what you want?



The ^ character means to start at the beginning of a line.



The dot character matches anything and the asterisk that follows it means to match zero to all



The text "shell" should match "shell".



Then, we have another dot followed by an asterisk which will match anything any number of times



Finally, we have the dollar sign $ which matches the end of the line.



Learning regular expressions can be very useful. They work pretty much the same in many programming languages *and* in many editors.



I recently used regular expressions in a text file of data that was about 5000 lines long to remove the initial space which I didn't want there.



I recently used regular expressions in a text file of code that had line numbers in and I easily eliminated all of the line numbers using a regular expression in my text editor.



Here's a link to a tutorial on regular expressions:



http://www.regular-expressions.info/tutorial.html
?
2016-10-26 08:49:25 UTC
do you're waiting to wish to coach huge-spread expressions? better acceptable to attempt this because RE are expensive: int code=-a million; if(string!=null&&string.startsWith("TA..... { String codeString=string.substring(2); code=Integer.parseInt(codeString);// may want to seize style format exception }
?
2016-10-25 11:33:04 UTC
do you're waiting to wish to coach huge-spread expressions? better acceptable to attempt this because RE are expensive: int code=-a million; if(string!=null&&string.startsWith("TA..... { String codeString=string.substring(2); code=Integer.parseInt(codeString);// may want to seize style format exception }


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...