Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In the regular expressions i'm confusing about the following expressions.

HTML
.*

HTML
*?

HTML
+?

HTML
??


How the above expressions works.
Can anybody give me with an examples.

What I have tried:

I've researched on google, but while working with the mentioned expressions I'm confusing.
Posted
Updated 3-May-16 1:28am

OK...
.* is "any character, any number of times (including zero)"
.*? is "and character, any number of times (including zero), as few as possible"
.+? is "any character, at least one of, as few as possible"
.?? is "any character, zero or one of, as few as possible"
And
.? is "any character, zero or one of"

Get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions. It really helps to understand (and test) them!
 
Share this answer
 
As an addition to OriginalGriff's answer, you can try this website:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns[^]
Here you can read greedy quantifiers: Regular Expressions Reference: Quantifiers[^]
It pretty much explains all about regular expressions.

The tool I usually us is the RegExTest.exe. It is very simple to get started with, but good together with .NET.
It is also free and can be downloaded here: RegExTest download | SourceForge.net[^]
 
Share this answer
 
In addition to previous solutions, here is a tool that can help to understand a RegEx
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
and documentation to one of the most common dialects
perlre - perldoc.perl.org[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900