When to use study option (S) of regular expressions? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
afe
Posts: 615
Joined: 06 Dec 2018, 04:36

When to use study option (S) of regular expressions?

25 Nov 2020, 06:04

The study option (S) can sometimes improve the performance of a regular expression that is used many times (such as in a loop).
Does this mean that just using this option in a loop can improve performance?
User avatar
mikeyww
Posts: 26947
Joined: 09 Sep 2014, 18:38

Re: When to use study option (S) of regular expressions?  Topic is solved

25 Nov 2020, 06:29

Yes, it means that it might.
Studies the pattern to try improve its performance. This is useful when a particular pattern (especially a complex one) will be executed many times. If PCRE finds a way to improve performance, that discovery is stored alongside the pattern in the cache for use by subsequent executions of the same pattern (subsequent uses of that pattern should also specify the S option because finding a match in the cache requires that the option letters exactly match, including their order).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Ineedhelplz, Spawnova and 242 guests