1
jsliu111
unclear code in MyTextSanitizerExtension class
  • 2009/3/3 7:57

  • jsliu111

  • Just popping in

  • Posts: 2

  • Since: 2008/10/7


In the method codePreConv()
$patterns "/[code([^]]*?)](.*)[/code]/esU";
            
$replacements "'[code\1]'.base64_encode('\2').'
'";
$text = preg_replace($patterns, $replacements, $text);[/code]

the regular expression [code([^\]]*?)\], why do we need the "?" after "*"?

As I know, the [code([^\]]*)\] still works.
E.g. The original string is "[codeabcd]", the expression [code([^\]]*)\] still can get it. So can I delete the "?" from the expression?

2
zyspec
Re: unclear code in MyTextSanitizerExtension class
  • 2009/3/3 15:20

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


The question mark in the regex makes the asterisk lazy, to make sure it stops before the first closing tag rather than before the last one, like a greedy asterisk would do.

Login

Who's Online

146 user(s) are online (90 user(s) are browsing Support Forums)


Members: 0


Guests: 146


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits