Results 1 to 2 of 2

Thread: split a string by 3 condition .......pls help

  1. #1
    Join Date
    Oct 2008
    Posts
    40
    Thanks
    3
    Thanked 1 Time in 1 Post

    Smile split a string by 3 condition .......pls help

    hello,

    i want to split a string by 3 condition.
    1)<​f​o​n​t​ ​s​t​y​l​e​=​"​c​o​l​o​r​:​ ​b​l​u​e​;​ ​b​a​c​k​g​r​o​u​n​d​-​c​o​l​o​r​: yellow;">
    2)</font>
    3)rest of the string.

    suppose string is as bellow ........(string is created dynamically so len is not specific)
    <​f​o​n​t​ ​s​t​y​l​e​=​"​c​o​l​o​r​:​ ​b​l​u​e​;​ ​b​a​c​k​g​r​o​u​n​d​-​c​o​l​o​r​: yellow;"> ​h​i </font> hihisadsadasdfsdffasdf
    <f​o​n​t​ ​s​t​y​l​e​=​"​c​o​l​o​r​:​ ​b​l​u​e​;​ ​b​a​c​k​g​r​o​u​n​d​-​c​o​l​o​r​: yellow;"> hi</font>

    ​​output
    suppose a is array :

    a[0]=><​f​o​n​t​ ​s​t​y​l​e​=​"​c​o​l​o​r​:​ ​b​l​u​e​;​ ​b​a​c​k​g​r​o​u​n​d​-​c​o​l​o​r​: yellow;">
    a[1]=>h​i
    a[2]=></font>
    a[3]=>hihisadsadasdfsdffasdf
    a[4]=><f​o​n​t​ ​s​t​y​l​e​=​"​c​o​l​o​r​:​ ​b​l​u​e​;​ ​b​a​c​k​g​r​o​u​n​d​-​c​o​l​o​r​: yellow;">
    a[5]=>hi
    a[6]=></font>


    <​f​o​n​t​ ​s​t​y​l​e​=​"​c​o​l​o​r​:​ ​b​l​u​e​;​ ​b​a​c​k​g​r​o​u​n​d​-​c​o​l​o​r​: yellow;"> & </font> will remain same only the string will change from the whole string.

    please tell me how to split ..........................................

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Now, I don't extremely get how you want to split the string, but take a look at the split() function:
    http://www.w3schools.com/jsref/jsref_split.asp

    And regular expressions:

    http://www.javascriptkit.com/jsref/regexp.shtml
    Jeremy | jfein.net

Bookmarks

Posting Permissions

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