Web Analytics Made Easy -
StatCounter Regxp - CodingForum

Announcement

Collapse
No announcement yet.

Regxp

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regxp

    Hey guys, I have the following regxp .match()

    Code:
    debugtest = debugtest.match(/(/**/ jordan30001[CD])/)[1];
    what i want to do with this regxp is with the /**/ and what i want to do is make it match a 1 didgit number or a 2 didgit number for example

    10 jordan30001[CD]
    or
    1 jordan30001[CD]

    how would i acomplish this i know that i could change /**/ to \d\d but that would only find 2 numbers and not 1 if theres only 1

  • #2
    Code:
    debugtest = debugtest.match(/(\d{1,2})\sjordan30001\[CD\]/)[1];

    Comment


    • #3
      thank you very much.

      Comment


      • #4
        just so i dont make a new topic would this work or would i have to remove the quotations?

        Code:
        matchDataStruct = "/(\d{1,2}\s" + namedPlayer + "\[" + playerGuild + "\]\s(\d)+,(\d)+,*(\d)+)/";
        	emptyhtml = emptyhtml.match(matchDataStruct)[1];

        Comment


        • #5
          No this wouldn't work but it also won't help to remove the quotation marks.

          To assemble a regular expression as a concatenated string, you'll need to use the RegExp constructor like this
          Code:
          matchDataStruct = new RegExp("/(\d{1,2}\s" + namedPlayer + "\[" + playerGuild + "\]\s(\d)+,(\d)+,*(\d)+)/");

          Comment


          • #6
            thanks again

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎