Module:User:Erutuon/patterns/documentation

Contains a function that determines if a pattern will behave in exactly the same way in both the basic Lua string functions (lua) and the Ustring functions (lua). This assumes text is validly encoded in UTF-8, the encoding used by MediaWiki.

Beware: the function tells you that a pattern requires the Ustring functions if it contains character classes (lua. But this is not always true. It depends what characters you actually need the character class to match. For example, if you're matching language codes, which only contain ASCII, then the character class lua only needs to match ASCII alphabetic characters (lua (not, for instance, Greek alphabetic characters lua), and the basic string function can be used.

Usage
Don't use this in an actual template-invoked function to decide between lua and lua on the fly. That would be very inefficient. If you want, use it to test a pattern and decide whether lua will work just as well as lua in a given instance. Switching to lua saves a noticeable amount of processing time if the function involves a lot of pattern-matching.

The function lua sends a message to the log if a lua function can be replaced by the corresponding lua function.