Split String using more than 1 criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Garima12
    New Member
    • Mar 2007
    • 58

    Split String using more than 1 criteria

    Hi,
    There is a string like:
    parcel = 1 AND id = 546 OR shape = 'point'

    I want to split this string with AND and OR

    I wrote split function like:
    var contentarr = qString2.split( "AND");
    it will split the string where the AND is but I want string to be broken:

    parcel = 1
    id = 546
    shape = 'point'

    How can I do this?
    Thanks
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    Use a regular expression to split the string on AND or OR-

    stringvalue.spl it(/AND|OR/);

    This returns an array that you can join with line break elements in html, or '\n' in plaint text.

    Comment

    Working...