Brothersoft.comWindows|Mac|Mobile|Games

|Message

Solve software problem quickly Share experience to help others Improve the ability of solving problem
Tags:
Split String in Javascript

08/24/2011 01:25 by wawaslope

First answer posted by ArvindK at 08/24/2011 01:25
Add Your Answer
10~1000 characters in length CAPTCHA:
1 Answers
  • ArvindK
    1. Note that the split method can take up to 2 arguments, both the arguments are optional. The syntax for split is as follows
      string.split([separator][, limit])
      where separator specifies the character for separating the string and limit specifies limit on the number of splits.
    2. split() example :
    <html>
    <body><script type="text/javascript"> var str="Split String example"; document.write(str.split(" ") + "<br />"); document.write(str.split("") + "<br />"); document.write(str.split(" ",1) + "<br />"); document.write(str.split()); </script> </body>
    </html>


    The output of the above script is as follows:
    Split,String,example
    S,p,l,i,t, ,S,t,r,i,n,g, ,e,x,a,m,p,l,e
    Split
    Split String example

    Tips

    • If an empty string ("") is used as the separator, the string is split between each character.
    • When the separator is defined in the split, separator is removed from the string and the sub-strings are returned in an array.
    • When the string is empty, split returns an array containing one empty string, rather than an empty array.
  • Was this answer helpful? 00 · 08/24/2011 01:25
Add Your Answer
10~1000 characters in length CAPTCHA:
Related Questions
Q:Create an if else Statement in Javascript

A:If else statements can be used in three different ways.if statement if...else statement if...else if....else statement If statement&nbs...(more)

Q:Declare a Variable in Javascript

A:Declaring Javascript variables : In Javascript variables are created using "var" keyword. When using a variable for the first time it is ...(more)

Q:Generate Random Numbers in JavaScript

A:Create a basic page up with your head, body and the like. Open a Open up the page. Then enjoy the mass of pseudo-random digits you have crea...(more)

Q:Enable JavaScript on Your Computer

A:IE 5 and 6 Open Internet Explorer Select Internet Options from the Tools menu. In Internet Options dialog box select the Security tab. C...(more)

Q:Disable Right Click through Javascript

A:Add this JavaScript in the section, and it will work for Google Chrome and IE <script type="text/javascript"> var message = "Righ...(more)

0 people are following

Ask a question now
Write a title for your question

JavaScript

Visual authoring lets Web and Intranet designers rapidly build JavaScrip.
Latest version:2.1
License:Shareware
OS:Windows XP/2000/98/Me/NT
Total downloads:1,124,224
Rank:1 in Site Management
Download It

Share with friends

New features is coming

  • 1. Providing high-quality answers to be a verified Q&A expert
  • 2. Ask and answer questions to get Brothersoft credits

Added Successfully!

×

Are you sure to delete your answer?

NoYes

×

Are you sure to choose it as the best answer?

NoYes

×

Voted Successfully!

×

You can't vote for yourself

×

You can't choose your own answer

×