# Matching open parenthesis outside double or single quotes.md
# Copyright (c) 2019 Evandro Coan
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-
Open and close parenthesis expressions outside single and double quotes:
".*?"(*SKIP)(?!)|(?<!\w)'.*?'(?!\w)(*SKIP)(?!)|(?:\()(?!\s|\)) ".*?"(*SKIP)(?!)|(?<!\w)'.*?'(?!\w)(*SKIP)(?!)|(?<!\s|\()(?:\))
- https://regex101.com/r/OFeXIh/1/
- https://stackoverflow.com/questions/26003778/can-regex-match-all-the-words-outside-quotation-marks
Now, not matching open and close parenthesis preceded by
def
and neither inside triple single or double quotes:(?s)".*?"(*SKIP)(?!)|(?<!\w)'.*?'(?!\w)(*SKIP)(?!)|(?s)""".*?"""(*SKIP)(?!)|(?<!\w)'''.*?'''(?!\w)(*SKIP)(?!)|def[^(]*\((*SKIP)(*F)|(?:\()(?!\s|\)) (?s)".*?"(*SKIP)(?!)|(?<!\w)'.*?'(?!\w)(*SKIP)(?!)|(?s)""".*?"""(*SKIP)(?!)|(?<!\w)'''.*?'''(?!\w)(*SKIP)(?!)|def[^)]*\)(*SKIP)(*F)|(?<!\s|\()(?:\))
Now, and no class word:
(?s)".*?"(*SKIP)(?!)|(?<!\w)'.*?'(?!\w)(*SKIP)(?!)|(?s)""".*?"""(*SKIP)(?!)|(?<!\w)'''.*?'''(?!\w)(*SKIP)(?!)|(?:def|class)[^(]*\((*SKIP)(*F)|(?:\()(?!\s|\)) (?s)".*?"(*SKIP)(?!)|(?<!\w)'.*?'(?!\w)(*SKIP)(?!)|(?s)""".*?"""(*SKIP)(?!)|(?<!\w)'''.*?'''(?!\w)(*SKIP)(?!)|(?:def|class)[^)]*\)(*SKIP)(*F)|(?<!\s|\()(?:\))
-
Match everything all the lines which does not has the word
c=50
and does not has anything on the formc=\d\d
:c=50(*SKIP)(*F)|c=\d\d