newbie question: Regular expression lookbehind?

C

cjl

JS:

I've read that javascript regular expression do not have 'lookbehind'
functionality.

Given the following text:

class monkey(blah):

I would like to contruct a regular expression that matches 'monkey'.
So far I have:

new RegExp("^\\s*class\\s([A-Za-z]+)", 'gm')

How do I ignore 'class' without a lookbehind?. I think my regular
expression is returning two groups:
0: class monkey
1: monkey

I only want it to return the second group.

Can anyone point me in the right direction?
Thanks in advance,
cjl
 
M

Martin Honnen

cjl said:
new RegExp("^\\s*class\\s([A-Za-z]+)", 'gm')

How do I ignore 'class' without a lookbehind?. I think my regular
expression is returning two groups:
0: class monkey
1: monkey

I only want it to return the second group.

Can anyone point me in the right direction?

Use that expression, call the exec method and access the second item in
the returned array.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top