Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is the package threadsafe?

package threadsafe
0
10 Posted

Is the package threadsafe?

0
10

Yes, by design. Once a RE object is compiled, it is never modified. Runtime data is attached to REMatch objects, which are created for each thread executing one of the match methods. Subexpression Indices I have a regular expression that looks like “(Hello)World|(Foo)Bar”. When I try to match the text “HelloWorldFooBar”, the first match returns “HelloWorld” and its first subexpression is “Hello”, both of which are correct. For the second match I get “FooBar”, but the first subexpression is empty. What gives? The behavior is correct. The subexpressions are numbered according to their position in the entire regular expression. Therefore the subexpression that matches “Foo” in the second match is subexpression number two.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123