all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
14
Task/Substring-Top-and-tail/Java/substring-top-and-tail.java
Normal file
14
Task/Substring-Top-and-tail/Java/substring-top-and-tail.java
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
public class RM_chars {
|
||||
public static void main( String[] args ){
|
||||
System.out.println( "knight".substring( 1 ) );
|
||||
System.out.println( "socks".substring( 0, 4 ) );
|
||||
System.out.println( "brooms".substring( 1, 5 ) );
|
||||
// first, do this by selecting a specific substring
|
||||
// to exclude the first and last characters
|
||||
|
||||
System.out.println( "knight".replaceAll( "^.", "" ) );
|
||||
System.out.println( "socks".replaceAll( ".$", "" ) );
|
||||
System.out.println( "brooms".replaceAll( "^.|.$", "" ) );
|
||||
// then do this using a regular expressions
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue