Remove leading whitespaces using variable length lookbehind in RegExp

Posted by Shizhidi on Stack Overflow See other posts from Stack Overflow or by Shizhidi
Published on 2010-05-07T08:39:53Z Indexed on 2010/05/07 8:48 UTC
Read the original article Hit count: 272

Filed under:
|
|

Hello, I'm wondering if variable length lookbehind assertions are supported in JavaScript's RegExp engine?

For example, I'm trying to match the string "variable length" in the string "[a lot of whitespaces and/or tabs]variable length lookbehind", and I have something like this but it does not go well in various RegExp testers:

^(?<=[ \t]+).+(?= lookbehind)

If it's an illegal pattern, what would be a good workaround to it? Thanks!

© Stack Overflow or respective owner

Related posts about regex

Related posts about JavaScript