Thanks for all your replies, I appreciate it. Philip M, your piece of code is great. It's nearly perfect for what I want to do and it's only not perfect because I didn't give enough information about what I needed. I hope you can help me perfect it.
Cranford, your code would indeed work for this particular string but I also need it to work for different ones.
oesxyl, your approach was something I was trying at first as well, but it doesn't work, first of all because I don't want the numbers quoted and second of all because I won't be working with just one string like the example I posted. That's of course again an error on my part, I did not provide enough information. Thanks, though.
As to Philip M's piece of code, it also doesn't work for more than one of these strings (I've actually got a set of these types of string which are also comma-seperated) but that was easily fixed by adding a global flag. However, the text I'm manipulating doesn't contain only the basic a-z letters, but also letters with accents, such as ë. Is there a specific subset of characters that I can include to extend the functionality of the code to these characters, or will I have to add them manually?
EDIT: Oh, I forgot the most important thing I wanted to post about. You're using $1 and $2. I'm assuming these are placeholders for what you are replacing, or something? I was looking for something like that but I didn't have any luck finding anything like this. It's of course perfect for my purpose, but would someone tell me how they work, or link me somewhere or just tell me what these things are called so I can compose a search phrase that will actually get me some information?
Last edited by NanakiXIII; 08-22-2008 at 08:44 PM..
var re = new RegExp("d(b+)(d)","ig");
var str = "cdbBdbsbdbdz";
var arr = re.exec(str);
s = "$1 contains: " + RegExp.$1 + "\n";
s += "$2 contains: " + RegExp.$2 + "\n";
s += "$3 contains: " + RegExp.$3;
Last edited by Philip M; 08-23-2008 at 09:17 AM..
Reason: Add demo