...

View Full Version : Regxp



jordandap
08-30-2011, 08:10 AM
Hey guys, I have the following regxp .match()


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

devnull69
08-30-2011, 08:59 AM
debugtest = debugtest.match(/(\d{1,2})\sjordan30001\[CD\]/)[1];

jordandap
08-30-2011, 09:36 AM
thank you very much.

jordandap
08-30-2011, 10:54 AM
just so i dont make a new topic would this work or would i have to remove the quotations?


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

devnull69
08-30-2011, 12:31 PM
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


matchDataStruct = new RegExp("/(\d{1,2}\s" + namedPlayer + "\[" + playerGuild + "\]\s(\d)+,(\d)+,*(\d)+)/");

jordandap
08-30-2011, 12:43 PM
thanks again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum