Jump to content

[SOLVED] What does .* mean?


eXeCuTeR

Recommended Posts

. is a metacharacter which matches all characters except a new line. It encompasses all characters if the /s modifier is used.

 

* is a quantifier which will try to match as many characters as possible, but is allowed to match nothing at all.

 

Adding a ? to a quantifier makes it lazy. By default, all quantifiers try to match their maximum first. When made lazy, they try to match their minimum first.

Link to comment
Share on other sites

Oh, the . quantifier matches only 1 character?

 

. is not a quantifier--it's a metacharacter.

 

Anything without a quantifier is expected to match once. It makes sense if you think about it. If you type "a" in your pattern, you expect it to match just "a"--not "aa", "aaa", "aaaaa", etc. Therefore, this same logic applies to metacharacters.

Link to comment
Share on other sites

No need to be a smartass. We know it doesn't literally mean that number I posted. I was just trying to explain in a way that would be easily understandable since he doesn't know much about regex.

 

What Daniel posted is the correct syntax for those quantifiers. Just because "we" know, doesn't mean the people reading this post do. There's no need to call someone a smart ass for correcting you.

Link to comment
Share on other sites

Okay I think there's a misunderstanding.

 

I was trying to explain how the quantifiers work to the person that did not understand how they work. So saying {1,} probably would have made no sense to him. It's usually safe to assume that a long line of 99999s means infinity in such a case.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.