You must Sign In to post a response.
  • Category: JavaScript

    Find the <<>> character in string

    Hi friends,

    i have strings like below
    eg:1
    var a = <<sachu>>
    eg2:
    var a = <sachu>
    eg3:
    var a = <<<<<john>>>

    in the string if i am having < or > i want to return some value like 0 or 1 ...based on that i ll work on
    if i found atleast one < or > i want to return some value

    how can we achive via javascript ... simple function plz


    thaks,
    saravanan
  • #756516
    Hai Saravanan,
    You can use IndexOf with the JavaScript to search the index of the particular character or the string.

    var a = "<<<<<john>>>";
    int idx = a.IndexOf("<");
    alert ("index of < is" + idx);

    You can also go through the below link for the workaound if you are still having any issues:

    http://stackoverflow.com/questions/273789/is-there-a-version-of-javascripts-string-indexof-that-allows-for-regular-expr

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #756519
    thx Pawan


  • Sign In to post your comments