About regular expression

Posted by Tkl1129 on Wed 06 Jul 2011 09:16 AM — 2 posts, 14,412 views.

Hong Kong #0
1. Whats the different between (.+?) , (.*?) ? I do serval testing but still don't know the difference between.

2. How regular expression apply to Alias? when will use that to match the things type in?

seems Alias : abc * & contenr : if xxx else xxx
it totally same case? or have other usage?

Thanks
Australia Forum Administrator #1
Quote:

1. Whats the different between (.+?) , (.*?) ?


.+ matches one or more of any character.

.* matches zero or more of any character.

The ? means "non greedy". In the case of .* the least number it could match would be zero. In the case of .+ the least number it could match would be one.

Template:regexp
Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.


Scroll down to "greedy matches".

I don't understand the second question. Can you give an example?