Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Regxp

  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 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
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,395
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Code:
    debugtest = debugtest.match(/(\d{1,2})\sjordan30001\[CD\]/)[1];

  • Users who have thanked devnull69 for this post:

    jordandap (08-30-2011)

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 Posts
    thank you very much.

  • #4
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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];

  • #5
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,395
    Thanks
    12
    Thanked 569 Times in 562 Posts
    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)+)/");

  • Users who have thanked devnull69 for this post:

    jordandap (08-30-2011)

  • #6
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 Posts
    thanks again


  •  

    Posting Permissions

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