1

Simple question...

I am trying to make this regex work with C functions regcomp/regexec. It does not.

(?=.*\d.*)(?=.*[a-zA-Z].*).{6,10}

Two questions:

  1. What does: ?=.* mean? Could you please break this down in simple terms?

  2. Why doesn't this work with regcomp().

I know your inclination is to tell me what a fool I am, and how dare me come in here and ask such a question. Google it you _. Thanks, okay I am an idiot, I know. Okay. Ha ha the joke is on me and I am public about my silly newbie questions.

BTW I am well aware of the fact that regex syntax is different from one system to another. That is my frustration with this.

Alan Moore
  • 68,531
  • 11
  • 88
  • 149
  • 1
    possible duplicate of [Reference - What does this regex mean?](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – Toto Apr 10 '14 at 09:11

1 Answers1

1

1: (?= ... ) is a lookahead. It checks to see if the RegEx inside is found behind your string. In this case, it is checking if your string contains at least a digit and any case character; also the entire string should be between 6 and 10 characters in length.

Also, it's not working because it needs to be: (?=.*\d)(?=.*[a-zA-Z])^.{6,8}$.

tenub
  • 3,240
  • 1
  • 14
  • 25