Global flag requirement

Global flag

Hi all

if we’ve specified to search at the start and end of the thread in the regex string, why do we need the global flag at the end?

Thank you.

2 Likes

you can’t select the spaces at the start and at the end at the same time, so you need the g flag to select all instances that match the pattern, one instance is the spaces at the beginningh of the string, one the spaces at the end, so that both can be replaced by the method

6 Likes

Ah yes, I see that now. Otherwise it would just find the match at the start then stop, rather than find them both together.

Thanks for the speedy response!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.