3

Google is failing me because ?= is not searchable. What does

(?=[aeiouy])

match -- specifically ?=, I know that [aeiouy] is any of aeiouy.

2
  • 1
    Google is not always be the best place to start. If you're looking for information regarding Regular Expressions, you'd better to visit regular-expressions.info first. Commented Dec 14, 2010 at 20:13
  • Or you can just figure out what you can search for. eg: "javascript regex syntax" turns up some promising results. The first one has the answer to your question. Commented Dec 14, 2010 at 20:19

4 Answers 4

6

?= is the positive lookahead syntax, it matches anything followed by a vowel here.

Sign up to request clarification or add additional context in comments.

1 Comment

5

It matches any place where the next character is an a, e, i, o, u or y, but it doesn't match that character - see http://www.rubular.com/r/Tjq3ocLMVJ

Specifically, (?=...) is called a "lookahead" and it verifies that the following chunk is present

Comments

3

From MDC:

x(?=y)

Matches x only if x is followed by y.

For example, /Jack(?=Sprat)/ matches 'Jack' only if it is followed by 'Sprat'. /Jack(?=Sprat|Frost)/ matches 'Jack' only if it is followed by 'Sprat' or 'Frost'. However, neither 'Sprat' nor 'Frost' is part of the match results.

So:

foo(?=[aeiouy])

Would match fooe, fooi etc. but not foo alone, but as already stated in the quote, the vowel in this case will not be included in the match itself.

Comments

0

Let's say your string is "bbbbae", then "(?=[aeiouy])" matches either the 'a' or the 'e', when applied anywhere before 'a'.

1 Comment

Not really. It doesn't match the character, it matches the empty space before the character. And it does so only exactly between b and a and between a and e, not just "anywhere before a".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.