difference between regex .*? and .+?

2,561 views
Skip to first unread message

Will Helton

unread,
Mar 24, 2015, 7:36:21 AM3/24/15
to cafetra...@googlegroups.com
I thought I had made a note of this, but I haven't. :(

What is the difference between .*? and .+? in regex?

Thanks,

Will

Hans list

unread,
Mar 24, 2015, 1:12:19 PM3/24/15
to cafetra...@googlegroups.com
You could type a test sentence with different punctuation marks, e.g.:

Franz (1) jagt 1. im komplett, verwahrlosten Taxi! quer durch Bayern.

And search for different parts. Write down your observations (which expression does span/include what?) and publish them here :).

Will Helton

unread,
Mar 24, 2015, 1:45:33 PM3/24/15
to cafetra...@googlegroups.com
As we say in Alabama:

Do what?

I have no idea what you mean. :D

It's not a biggie. I'll test these as I go along and make a note of what I get.

Cheers,

Will
> --
> You received this message because you are subscribed to the Google
> Groups "CafeTranslators" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cafetranslato...@googlegroups.com
> <mailto:cafetranslato...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Hans van den Broek

unread,
Mar 24, 2015, 7:59:23 PM3/24/15
to Cafetran support
Context? 

I don’t think there is a difference, if used in combination. The will both “Match[es] 0 or more of the preceeding token. This is a lazy match, and will match as few characters as possible before satisfying the next token.” (according to RegExr)


Cheers,

Hans

-- 

Hans van den Broek
Schrijf-, vertaal- en redigeerwerk





--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Igor Kmitowski

unread,
Mar 25, 2015, 4:10:35 AM3/25/15
to cafetra...@googlegroups.com
Hi Will,

> I thought I had made a note of this, but I haven't. :(
>
> What is the difference between .*? and .+? in regex?

.*? = any character zero or more times.

.+? = any character one or more times.

Cheers,
Igor

--
Igor Kmitowski
Translator and Java developer
CafeTran website: http://www.cafetran.com
CafeTran support: cafetran...@gmail.com
Reply all
Reply to author
Forward
0 new messages