Results 1 to 4 of 4
  1. #1
    vysh is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default [SOLVED] split("\\d")

    Hi all,

    Can anyone tell me the options a split() function can have as arguments. It can have characters like split("a"),split(","). Can anyone tell me other arguments. Especially what does split("\\d") mean?

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    837
    Rep Power
    6

    Default

    Hi Vysh,
    \\d indicates ->Any number between 0 to 9 is used for delimiting a given String.

    sample code:

    Java Code:
    // Imports
    
    class Test
    {
    	public static void main(String args[])
    	{
    		String s ="Hi1 ramya";
    		String[] finalOutput = s.split("\\d");
    		for(int i=0;i<finalOutput.length;i++)
    		{
    			System.out.println("Result  "+finalOutput[i]);
    		}
    	}
    	
    }
    
    Output :D:\Research>java Test
    Result  Hi
    Result   ramya
    Last edited by RamyaSivakanth; 05-20-2009 at 12:45 PM.
    Ramya:cool:

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It's called a regular expression or regex for short. For more information on regular expressions, a powerful new addition to the Java language, please check out this link: Regular Expressions

    Per this tutorial: Regular expressions are a way to describe a set of strings based on common characteristics shared by each string in the set. They can be used to search, edit, or manipulate text and data.

  4. #4
    vysh is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

Similar Threads

  1. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  2. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  3. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  4. <core:forEach var="" begin="+<%=j%>+">???
    By freddieMaize in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2008, 01:20 AM
  5. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •