Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8578283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:21:08+00:00 2026-06-11T20:21:08+00:00

I need a regular expression to test if strings are in a specific palette

  • 0

I need a regular expression to test if strings are in a specific palette of values for example string dir ca only be ltr, rtl, lro, rlo, or another example bool can be only false, true.

What regular expression, can I use to test a string like dir and bool against a limited set of values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:21:09+00:00Added an answer on June 11, 2026 at 8:21 pm

    Do you mean something like '^(ltr|rtl|lro|rlo)$' and '^(true|false)$'?

    this can even be easily automated:

    def make_re(args):
        args = (re.escape(arg) for arg in args) #if you want to escape special characters
        return re.compile('^({0})$'.format('|'.join(args)) )
    
    boolre = make_re(('true','false'))
    

    However, if you leave the line args = (re.escape(arg) ...) in there, then you really don’t gain anything beyond what you could get using if arg in myset: .... The beauty of the unescaped version is that you still have at least some of the regex flexibility.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this ch:keyword ch:test ch:some_text I need a regular expression
I need to use a long string for testing regular expression. However, the test
I need an regular expression which matches the following: 'test foo bar, test' =>
I need a regular expression able to match everything but a string starting with
I need a regular expression to extract from two types of URIs http://example.com/path/to/page/?filter http://example.com/path/to/?filter
I need a regular expression to basically get the first part of a string,
I need help with a regular expression that will find matches in the strings
I have a string: $uri = start/test/go/; Basically I need to know which regular
I'm looking for a regular expression that which will match a string ##test## in
How I can write regexp to variable in regular expression? $string = 'Test regular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.