Question:

Need help defining this in RegEx (regular expression)

by Guest33150  |  earlier

0 LIKES UnLike

Sort and find all occurrences of (AA ) where there is a parenthesis, and at least two characters (anything, letter or number, etc), followed by a closing parenthesis.

So it would sort out:

(Test)

(Goodies)

(Ba)

(Wanna Be)

but would exclude:

(a)

(b)

(1)

Thanks for this to the folks who understand RegEx well!

 Tags:

   Report

2 ANSWERS


  1. \([a-zA-Z0-9 ]{2,}\)


  2. I don't know what programming language you use, but I use Python. Here is the RegEx in Python syntax

    ---------------

    import re

    regex = re.compile(r"(\(.{2,}\))")

    regex.search(text_to_search)

    ---------------

    In the example, the RegEx is "(\(.{2,}\))". The outer set of parenthesis capture the text and the parenthesis. The inner set of parenthesis are escaped, so they match literally. The period, ".", matches anything, including spaces. The curly brackets, "{" and "}", limit how many characters to match, in the form of {min., max.}.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions