General Question

Anaphase's avatar

Does Javascript support conditional if/then regular expressions?

Asked by Anaphase (768points) August 14th, 2008

I’ve been trying to find an article about this, but all my searches were futile. I usually try to not bog Fluther down with questions if I can find the answer by searching, but this is a rare case. Anyway, I want to know because I’ve been trying to write a regular expression with an if/then/else conditional in it, and Javascript is throwing errors at me left and right. I’m not sure if I’m just doing it wrong or if Javascript doesn’t support if/thens in regular expressions.

Any help would be appreciated.

Observing members: 0 Composing members: 0

2 Answers

paulc's avatar

Javascript is an ECMA language whose regex implementation sadly doesn’t include the conditional syntax. Here’s a very thorough reference chart in case you’re curious about other implementations.

Anaphase's avatar

Well, that sucks. But thanks for the reference, should help me in the future.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther